◐ Shell
clean mode source ↗

bpo-23403: [lib2to3] Make grammar pickling faster by ambv · Pull Request #6491 · python/cpython

@ambv

  • Now uses pickle protocol 4

  • Doesn't wrap the grammar's __dict__ in ordered dictionaries anymore as
    dictionaries in Python 3.6+ are ordered by default

This still produces deterministic pickles (that hash the same with MD5).
Tested with different PYTHONHASHSEED values.

https://bugs.python.org/issue23403

* Now uses pickle protocol 4

* Doesn't wrap the grammar's `__dict__` in ordered dictionaries anymore as
dictionaries in Python 3.6+ are ordered by default

This still produces deterministic pickles (that hash the same with MD5).
Tested with different PYTHONHASHSEED values.

@ambv ambv changed the title [lib2to3] Make grammar pickling faster bpo-23403: [lib2to3] Make grammar pickling faster

Apr 16, 2018

gpshead

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a very good idea. The grammar pickle is a cache.

I wish we'd generate it at CPython build time rather than ever do the runtime load and save a cache thing. But that's a separate feature request.

@ambv

The grammar pickle is a cache.

Yeah, and that cache is over twice as small with protocol 4 :)

I wish we'd generate it at CPython build time rather than ever do the runtime load and save a cache thing.

Yeah, that would make my life easier ;)

@bedevere-bot

@ambv: Please replace # with GH- in the commit message next time. Thanks!

@ambv ambv deleted the fastgrammarpickle branch

July 12, 2021 11:23