[Python-Dev] C api for built-in type set?

Raymond Hettinger raymond.hettinger at verizon.net
Mon Jul 25 23:03:45 CEST 2005


[Edward C. Jones]
> Is there a C API for the built-in type set? 
> if not, why not?

I decided not to expose the internals until the code was fully evolved.
For Py2.5, the underlying implementation is shifting to use its own data
structure instead of forwarding everything to dictionaries.  That will
save a substantial amount of memory and offer a tiny speed boost.  See a
fully-tested draft implementation in nondist/sandbox/set.

Of course, you already know that you can use the PyObject_Call() and its
brethren to access sets and set methods.  The regular, external set API
works pretty well with this approach (many methods accept any iterable).
The only inefficiencies that arise are with fine grained methods like
__contains__() and add(); even then, it is no less efficient than pure
Python.


Raymond Hettinger



More information about the Python-Dev mailing list