gh-122459: Optimize pickling by name objects without __module__#122460
gh-122459: Optimize pickling by name objects without __module__#122460serhiy-storchaka merged 2 commits intopython:mainfrom
Conversation
|
There are some pickle benchmarks in the benchmark suite. I don't know if they exercise this case (objects without |
|
This does seem to make the unpickle_pure_python benchmark about 2% slower. I haven't dug in to see whether it exercises the case where |
|
2% is so small difference, that it is most likely a random fluctuation or the compiler fluke. Indeed, the test data does not contain functions or other objects that can be be affected by this change. On other hand, the following example (pickling a function without import sys
sys.modules['_pickle'] = None
import pickle, timeit
def f():
pass
f.__module__ = None
print(min(timeit.repeat('pickle.dumps(f)', globals=globals(), number=10**4))) |
Uh oh!
There was an error while loading. Please reload this page.