This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients alexandre.vassalotti, brett.cannon, georg.brandl, kbengine, pitrou, vstinner
Date 2014-10-21.07:29:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413876584.39.0.63190497713.issue22676@psf.upfronthosting.co.za>
In-reply-to
Content
Note the problem is easily reproduce. For example we can take numpy where some ufuncs (i.e. function-like objects implemented in C) don't have a __module__.

$ PYTHONHASHSEED=0 python3.4 -m timeit -s "import pickle, numpy; d=numpy.add" "pickle.dumps(d)"
1000 loops, best of 3: 280 usec per loop
$ PYTHONHASHSEED=0 python3.4 -m timeit -s "import pickle, numpy; d=numpy.diff" "pickle.dumps(d)"
100000 loops, best of 3: 2.74 usec per loop

We see that pickling numpy.add (which doesn't have a __module__) is 100x slower than numpy.diff (which has a __module__)! Note I'm forcing PYTHONHASHSEED for consistent results, since whichmodule() uses dict iteration.

For comparison, 2.7 is fast enough:

$ PYTHONHASHSEED=0 python2.7 -m timeit -s "import cPickle as pickle, numpy; d=numpy.add" "pickle.dumps(d)"
100000 loops, best of 3: 6.12 usec per loop
$ PYTHONHASHSEED=0 python2.7 -m timeit -s "import cPickle as pickle, numpy; d=numpy.diff" "pickle.dumps(d)"
100000 loops, best of 3: 2.35 usec per loop

(varying PYTHONHASHSEED didn't produce any slower results)
History
Date User Action Args
2014-10-21 07:29:44pitrousetrecipients: + pitrou, brett.cannon, georg.brandl, vstinner, alexandre.vassalotti, kbengine
2014-10-21 07:29:44pitrousetmessageid: <1413876584.39.0.63190497713.issue22676@psf.upfronthosting.co.za>
2014-10-21 07:29:44pitroulinkissue22676 messages
2014-10-21 07:29:43pitroucreate