[Python-Dev] are CObjects inherently unsafe? (original) (raw)

Martin v. Löwis martin at v.loewis.de
Thu Dec 4 14:37:07 EST 2003


Michael Hudson <mwh at python.net> writes:

It seems to me that it would be more sensible to have a dict mapping names (maybe just module names...) to cobjects in the interpreter state. I guess there might be a way of getting ahold of the dict with the gc module (though I can't think of one off hand). This wouldn't be a difficult change, and if the CObjects are left in the module dicts, it shouldn't even do that much damage to binary compatibility.

Thoughts?

Good idea. Alternatively, we could make "APIs" a feature of modules: PyModule_GetAPI, PyModule_SetAPI. We would then define

typedef struct { PyObject_HEAD PyObject *md_dict; PyObject *md_api; } PyModuleObject;

We could restrict md_api to CObjects, which, means we would not need to change module_traverse.

Regards, Martin



More information about the Python-Dev mailing list