[Python-ideas] RFC: PEP: Add dict.__version__
Victor Stinner
victor.stinner at gmail.com
Sat Jan 9 04:58:00 EST 2016
More information about the Python-ideas mailing list
Sat Jan 9 04:58:00 EST 2016
- Previous message (by thread): [Python-ideas] RFC: PEP: Add dict.__version__
- Next message (by thread): [Python-ideas] RFC: PEP: Add dict.__version__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2016-01-09 9:57 GMT+01:00 Serhiy Storchaka <storchaka at gmail.com>: >>> This also can be used for better detecting dict mutating during >>> iterating: >>> https://bugs.python.org/issue19332. > (...) > > This makes Raymond's objections even more strong. Raymond has two major objections: memory footprint and performance. I opened an issue with a patch implementing dict__version__ and I ran pybench: https://bugs.python.org/issue26058#msg257810 pybench doesn't seem reliable: microbenchmarks on dict seems faster with the patch, it doesn't make sense. I expect worse or same performance. With my own timeit microbenchmarks, I don't see any slowdown with the patch. For an unknown reason (it's really strange), dict operations seem even faster with the patch. For the memory footprint, it's clearly stated in the PEP that it adds 8 bytes per dict (4 bytes on 32-bit platforms). See the "dict subtype" section which explains why I proposed to modify directly the dict type. IMHO adding 8 bytes per dict is worth it. See for example microbenchmarks on func.specialize() which rely on dict.__version__ to implement efficient guards on namespaces: https://faster-cpython.readthedocs.org/pep_specialize.html#example "1.6 times" (155 ns => 95 ns) is better than a few percent as fast usually seen when optimizing dict operations. Victor
- Previous message (by thread): [Python-ideas] RFC: PEP: Add dict.__version__
- Next message (by thread): [Python-ideas] RFC: PEP: Add dict.__version__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list