cpython
cpython copied to clipboard
Multiple files use `tuple()`, `list()` and `dict()`
Bug report
Multiple files use tuple()
, list()
and dict()
, which can slow down performance.
You also try to change Exception or Exception
to just Exception
in test_bpo_42057
, even though BPO 42057 makes it look like the duplication is intentional and essential. Do you understand why it is the way it is? And can you explain why it's not needed? You didn't even mention that change. Looks like Chesterton's fence (good long post).
How much do those tuple()
etc calls slow down performance? And can you explain why they are the way they are, and why they don't need to be?
You also try to change Exception or Exception to just Exception in test_bpo_42057, even though BPO 42057 makes it look like the duplication is intentional and essential.
I have reverted this change.
How much do those tuple() etc calls slow down performance? And can you explain why they are the way they are, and why they don't need to be?
It can be inferred from this Stack Overflow answer that tuple()
is much slower that just ()
.
I know it's slower. And that answer shows differences of 140 nanoseconds. Is that even measurable in the cases you've changed?
I am not sure about that.
Per the PR discussion, marking as closed.
Also a few other comments might be helpful when thinking about this. Generally, we try to avoid sweeping through many modules at once because it risks destabilizing code and it makes it harder to backport actual bugfixes. Also, it is not wrong to write dict()
, list()
, or tuple()
. Sometimes that reflects the authors way of thinking about the problem and lets them highlight or call out the type for emphasis. Most of the edits in the PR were aimed at tests or tools where we really don't care about micro-performance.