mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
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:
parent
c105289ec4
commit
960b9b7a2f
4 changed files with 108 additions and 48 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue