Documentation on creating new types with slots in C ?
Alex Martelli
aleax at aleax.it
Fri Oct 17 12:03:32 EDT 2003
Thomas Heller wrote:
...
>>> Of what I heard Python 2.3 now allow creation of new types in C with
>>> slots.
...
> I would guess he means this:
>
> http://www.python.org/sf/696193
i.e. METAtypes (types whose instances are types) with '__slots__' ...?
> and I would also be interested in an example.
Sorry, I've never written a metatype in C -- always in Python, almost
invariably inheriting from the built-in type.
"Normal" C types don't _need_ __slots__ of course, since __slots__'s
effect (avoiding a per-instance dict) is most easily achieved by
simply leaving the tp_dictoffset field at 0 (as most built-in types
do, save for those who DO want a per-instance dict -- functions and
modules come to mind).
Alex
More information about the Python-list
mailing list