[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-11-02 Thread Inada Naoki
Inada Naoki added the comment: OK. Microbenchmark don't justify adding complexity to the eval loop and the compiler. -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Mark Shannon
Mark Shannon added the comment: It sounds like the root cause is that annotations are repeatedly being computed. We should address the underlying issue, IMO. -- ___ Python tracker

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Inada Naoki
Inada Naoki added the comment: It is difficult to estimate. Real world applications has different code-style than stdlib. And pyperformance didn't include whole real world applications too. Some application may use dict display in heavy loop. But it is difficult to say how much exactly. One

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Mark Shannon
Mark Shannon added the comment: Is this worthwhile? Statically, BUILD_CONST_KEY_MAP represents 0.14% of all bytecode instructions in the standard library, but only 0.03% of the bytecode instructions in functions. Which suggests that dynamically only 1 in 3000 instructions executed is

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Inada Naoki
Inada Naoki added the comment: $ ./python -m pyperf timeit --compare-to ~/pyenv/versions/3.10-dev/bin/python '{}' /home/inada-n/pyenv/versions/3.10-dev/bin/python: . 23.5 ns +- 0.2 ns /home/inada-n/work/python/cpython/python: . 22.4 ns +- 0.1 ns Mean

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Inada Naoki
Change by Inada Naoki : -- keywords: +patch pull_requests: +21842 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22911 ___ Python tracker ___

[issue42126] Optimize BUILD_CONST_KEY_MAP for distinct keys

2020-10-23 Thread Inada Naoki
New submission from Inada Naoki : BUILD_CONST_KEY_MAP can be optimized based on #41835 optimization. 1. compiler checks keys tuple is distinct. 2. Add distinct flag to BUILD_CONST_KEY_MAP oparg To be considered: * Should we use new opcode, instead of flag in oparg? * Is this technique safe?