aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-03 12:09:30 +0000
committerGuido van Rossum <guido@python.org>2001-10-03 12:09:30 +0000
commitf4593e0b657a29f93a74a578cb4d78aafdf384ea (patch)
tree7c8e2ba062e01c9100c05dd7593be2cf639240b4 /Include/descrobject.h
parentMade the classmethod docstring test a bit less trivial. (diff)
downloadcpython-f4593e0b657a29f93a74a578cb4d78aafdf384ea.tar.gz
cpython-f4593e0b657a29f93a74a578cb4d78aafdf384ea.tar.bz2
cpython-f4593e0b657a29f93a74a578cb4d78aafdf384ea.zip
*EXPERIMENTAL* speedup of slot_sq_item. This sped up the following
test dramatically: class T(tuple): __dynamic__ = 1 t = T(range(1000)) for i in range(1000): tt = tuple(t) The speedup was about 5x compared to the previous state of CVS (1.7 vs. 8.8, in arbitrary time units). But it's still more than twice as slow as as the same test with __dynamic__ = 0 (0.8). I'm not sure that I really want to go through the trouble of this kind of speedup for every slot. Even doing it just for the most popular slots will be a major effort (the new slot_sq_item is 40+ lines, while the old one was one line with a powerful macro -- unfortunately the speedup comes from expanding the macro and doing things in a way specific to the slot signature). An alternative that I'm currently considering is sketched in PLAN.txt: trap setattr on type objects. But this will require keeping track of all derived types using weak references.
Diffstat (limited to 'Include/descrobject.h')
-rw-r--r--Include/descrobject.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/Include/descrobject.h b/Include/descrobject.h
index 1671cebe1bf..b79c2faacc8 100644
--- a/Include/descrobject.h
+++ b/Include/descrobject.h
@@ -20,6 +20,40 @@ struct wrapperbase {
char *doc;
};
+/* Various kinds of descriptor objects */
+
+#define PyDescr_COMMON \
+ PyObject_HEAD \
+ PyTypeObject *d_type; \
+ PyObject *d_name
+
+typedef struct {
+ PyDescr_COMMON;
+} PyDescrObject;
+
+typedef struct {
+ PyDescr_COMMON;
+ PyMethodDef *d_method;
+} PyMethodDescrObject;
+
+typedef struct {
+ PyDescr_COMMON;
+ struct PyMemberDef *d_member;
+} PyMemberDescrObject;
+
+typedef struct {
+ PyDescr_COMMON;
+ PyGetSetDef *d_getset;
+} PyGetSetDescrObject;
+
+typedef struct {
+ PyDescr_COMMON;
+ struct wrapperbase *d_base;
+ void *d_wrapped; /* This can be any function pointer */
+} PyWrapperDescrObject;
+
+extern DL_IMPORT(PyTypeObject) PyWrapperDescr_Type;
+
extern DL_IMPORT(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
extern DL_IMPORT(PyObject *) PyDescr_NewMember(PyTypeObject *,
struct PyMemberDef *);