Re-apply patch #1700288 (first applied in r59931, rolled back in r59940)

now that ctypes uses a more supported method to create types:

Method cache optimization, by Armin Rigo, ported to 2.6 by Kevin Jacobs.
This commit is contained in:
Amaury Forgeot d'Arc 2008-01-14 00:29:41 +00:00
parent 08ccf202e6
commit e4c270c2a8
4 changed files with 219 additions and 6 deletions

View file

@ -345,6 +345,9 @@ typedef struct _typeobject {
PyObject *tp_weaklist;
destructor tp_del;
/* Type attribute cache version tag. Added in version 2.6 */
unsigned int tp_version_tag;
#ifdef COUNT_ALLOCS
/* these must be last and never explicitly initialized */
Py_ssize_t tp_allocs;
@ -529,6 +532,10 @@ given type object has a specified feature.
/* Objects support nb_index in PyNumberMethods */
#define Py_TPFLAGS_HAVE_INDEX (1L<<17)
/* Objects support type attribute cache */
#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18)
#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19)
/* 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)
@ -550,6 +557,7 @@ given type object has a specified feature.
Py_TPFLAGS_HAVE_CLASS | \
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
Py_TPFLAGS_HAVE_INDEX | \
Py_TPFLAGS_HAVE_VERSION_TAG | \
0)
#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)