Lambda going out of fashion

Skip Montanaro skip at pobox.com
Thu Dec 23 11:13:28 EST 2004


    Craig> IMO the reference behaviour of functions in the C API could be
    Craig> clearer. One often has to simply know, or refer to the docs, to
    Craig> tell whether a particular call steals a reference or is reference
    Craig> neutral.  Take, for example, PyDict_SetItemString vs
    Craig> PyMapping_SetItemString . Is it obvious that one of those steals
    Craig> a reference, and one is reference neutral? Is there any obvious
    Craig> rationale behind this? 

Sure.  PyDict_SetItemString was first written very early on in Python's
development (actually, it was originally called something
namespace-ly-dangerous like dict_setstring).  PyMapping_SetItemString (part
of the abstract objects api) was written later with an emphasis on the
consistency of behavior you desire.  You're generally going to be better off
sticking with the abstract objects api.  For obvious reasons of backward
compatibility, the concrete apis (PyDict_*, PyList_*, etc) must be retained.

Skip



More information about the Python-list mailing list