Author kbengine
Recipients kbengine
Date 2014-10-20.11:38:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I have an application, the use of Python3.2.3 development.
When I upgrade to Python3.4.2, found a problem.

I have an extended "xxx.c (c-python)" module, I call pickle to serialize and deserialize, _pickle.c calls the whichmodule to look for this module, The final will be to find the module from sys.modules.

But probably there are 200 elements in sys.modules, Use the "obj = getattribute (module, global_name, allow_qualname)" to try to get the object:

static PyObject *
getattribute(PyObject *obj, PyObject *name, int allow_qualname) {

        tmp = PyObject_GetAttr(obj, subpath);
// There will be hundreds of times to return to NULL
// There will be hundreds of times calls "PyErr_Format           
// (PyExc_AttributeError," Can't get attribute%R on%R ", name, obj);"
// This process will lead to hundreds of calls to "moduleobject.c-
// module_repr(PyModuleObject *m)".

// So I frequently call pickle.dumps CPU consumption sharply.

        if (tmp == NULL) {
            if (PyErr_ExceptionMatches(PyExc_AttributeError)) {

                             "Can't get attribute %R on %R", name, obj);
            return NULL;

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      315    0.001    0.000    0.004    0.000 <frozen importlib._bootstrap>:690(_module_repr)

I went wrong?
Look forward to answer, thanks!
Date User Action Args
2014-10-20 11:38:22kbenginesetrecipients: + kbengine
2014-10-20 11:38:22kbenginesetmessageid: <>
2014-10-20 11:38:22kbenginelinkissue22676 messages
2014-10-20 11:38:21kbenginecreate