[ You can use the capi-sig for questions like this; see http://mail.python.org/mailman/listinfo/capi-sig ]
Chris <[EMAIL PROTECTED]> writes: > I'd like to be able to access an attribute of a particular Python > object as fast as possible from some C code. > > I wondered if using __slots__ to store the attribute would allow me to > do this in a faster way. > > The reason I'd like to do this is because I need to access the > attribute inside a loop within some C code, and I find that the > attribute lookup using the 'PyObject_GetAttrString' call is far slower > than any of the subsequent calculations I perform in C. PyObject_GetAttrString is convenient, but it creates a Python string only so it can intern it (and in most cases throw away the freshly created version). For maximum efficiency, pre-create the string object using PyString_InternFromString, and use that with PyObject_GetAttr. -- http://mail.python.org/mailman/listinfo/python-list