[Python-Dev] C-level duck typing (original) (raw)

Mark Shannon mark at hotpy.org
Wed May 16 12:28:40 CEST 2012


Martin v. Löwis wrote:

> And, we want this to somehow work with existing Python; we still > support users on Python 2.4.

This makes the question out-of-scope for python-dev - we only discuss new versions of Python here. Old versions cannot be developed anymore (as they are released already).

typedef struct { unsigned long extensionid; void *data; } PyTypeObjectExtensionEntry;

and then a type object can (somehow!) point to an array of these. The array is linearly scanned It's unclear to me why you think that a linear scan is faster than a dictionary lookup. The contrary will be the case - the dictionary lookup (PyObjectGetAttr) will be much faster.

PyObject_GetAttr does a lot more than just a dictionary lookup.

Perhaps making _PyType_Lookup() public might provide what it is needed?

Just make sure to use interned strings, and to cache the interned strings. Regards, Martin


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/mark%40hotpy.org



More information about the Python-Dev mailing list