Accessing __slots__ from C

Chris ceball at
Thu Sep 11 22:12:52 CEST 2008

Hrvoje Niksic <hniksic <at>> writes:
> [ You can use the capi-sig for questions like this; see
> ]

Thanks, I had no idea about that.

> 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.

Yes, we'd thought of that too, but it doesn't seem to be an important
factor compared to the actual attribute lookup.

Thanks for the advice,

More information about the Python-list mailing list