New submission from kbengine: 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); Py_DECREF(obj); // 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)) { PyErr_Clear(); PyErr_Format(PyExc_AttributeError, "Can't get attribute %R on %R", name, obj); } Py_DECREF(dotted_path); 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! ---------- components: Extension Modules files: 20141020193031.jpg messages: 229723 nosy: kbengine priority: normal severity: normal status: open title: _pickle.c type: performance versions: Python 3.4 Added file: http://bugs.python.org/file36980/20141020193031.jpg _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22676> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com