[issue29737] Optimize concatenating empty tuples

2017-03-25 Thread STINNER Victor
STINNER Victor added the comment: I like the change. It prevents to duplicate tuples and so reduce the memory footprint. PGO compilation helps branch prediction anyway. -- ___ Python tracker

[issue29737] Optimize concatenating empty tuples

2017-03-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The PR already was merged when you wrote your comment Raymond. If you insist I can revert it. But 0f7b0b397e12514ee213bc727c9939b66585cbe2 depends on it. -- ___ Python tracker

[issue29737] Optimize concatenating empty tuples

2017-03-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue29737] Optimize concatenating empty tuples

2017-03-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 98e80c2babac0003182c3482c6c5437ea111e795 by Serhiy Storchaka in branch 'master': bpo-29737: Optimize concatenating with empty tuple. (#524) https://github.com/python/cpython/commit/98e80c2babac0003182c3482c6c5437ea111e795 --

[issue29737] Optimize concatenating empty tuples

2017-03-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I agree with your comments Raymond, but let me to expose my reasons. An idea of optimizing empty tuple concatenating is inspired by partial(). It concatenates two tuples of arguments and it is common when one of tuple is empty. Current C implementation

[issue29737] Optimize concatenating empty tuples

2017-03-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: Is it at all common to concatenate empty tuples? This seems like optimizing something that rarely occurs. Also, the timings can be misleading if in real code these changes cause new branch mispredictions here which can slow the common case. See

[issue29737] Optimize concatenating empty tuples

2017-03-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +432 ___ Python tracker ___ ___

[issue29737] Optimize concatenating empty tuples

2017-03-06 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: Since tuples are immutable, concatenating with empty tuple can be optimized by returning an opposite argument. Microbenchmarks (the difference is larger for larger tuples): $ ./python -m perf timeit --duplicate=100 -s 'a = (1, 2)' 'a + ()' Unpatched: