Move abc._Abstract into object by adding a new flag Py_TPFLAGS_IS_ABSTRACT,

which forbids constructing types that have it set. The effect is to speed

  ./python.exe -m timeit -s 'import abc' -s 'class Foo(object): __metaclass__ = abc.ABCMeta' 'Foo()'

up from 2.5us to 0.201us. This fixes issue 1762.
This commit is contained in:
Jeffrey Yasskin 2008-02-28 04:45:36 +00:00
parent c105289ec4
commit 960b9b7a2f
4 changed files with 108 additions and 48 deletions

View file

@ -537,6 +537,9 @@ given type object has a specified feature.
#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18)
#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19)
/* Type is abstract and cannot be instantiated */
#define Py_TPFLAGS_IS_ABSTRACT (1L<<20)
/* These flags are used to determine if a type is a subclass. */
#define Py_TPFLAGS_INT_SUBCLASS (1L<<23)
#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)