[Python-Dev] Discussion draft: Proposed Py2.5 C API for set and frozenset objects
Raymond Hettinger
raymond.hettinger at verizon.net
Sat Aug 13 13:34:34 CEST 2005
The object and types
--------------------
PySetObject subclass of object
used for both sets and frozensets
PySet_Type a basetype
PyFrozenSet_Type a basetype
The type check macros
---------------------
PyFrozenSet_CheckExact(ob) a frozenset
PyAnySet_CheckExact(ob) a set or frozenset
PyAnySet_Check(ob) a set, frozenset, or subclass of either
The constructors
----------------
obj PySet_New(it) takes an iterable or NULL; returns new
ref
obj PyFrozenSet_New(it) takes an iterable or NULL; returns new
ref
The fine grained methods
------------------------
int PySet_Size(so)
int PySet_Contains(so, key) 1 for yes; 0 for no; -1 for error
raises TypeError for unhashable key
does not automatically convert to
frozenset
int PySet_Add(so, key) 0 for success; -1 for error
raises TypeError for unhashable key
raises MemoryError if no room to grow
obj PySet_Pop(so) return new ref or NULL on failure
raises KeyError if set is emtpy
int PySet_Discard(so, key) 1 if found and removed
0 if not found (does not raise KeyError)
-1 on error
raises TypeError for unhashable key
does not automatically convert to
frozenset
Course grained methods left for access through PyObject_CallMethod()
--------------------------------------------------------------------
copy, clear, union, intersection, difference, symmetric_difference,
update,
intersection_update, difference_update, symmetric_difference_update
issubset, issuperset, __reduce__
Other functions left for access through the existing abstract API
-----------------------------------------------------------------
PyObject_RichCompareBool()
PyObject_Hash()
PyObject_Repr()
PyObject_IsTrue()
PyObject_Print()
PyObject_GetIter()
More information about the Python-Dev
mailing list