How do you copy a Dictionary object from C code?

Warren Postma embed at NOSPAM.geocities.com
Tue Jun 27 13:11:38 EDT 2000


Please Guido, add PyDict_Copy( dict ) to the API in the future!!!!

This is an annoying oversight in the Dictionary's design.  The dict_copy
method inside dictobject.c does the exact right job, but is well hidden
because it is a static function. It might be possible to look it up by
getting a reference to the Dictionary object's attribute named "copy" and
then calling it, somehow, but you can't even copy and paste dict_copy into
your own module because it has carnal knowledge of the internals of the
dictionary object.

Sigh. What is the best way in C to make a copy of a dictionary?

Warren





More information about the Python-list mailing list