[issue36791] sum() relies on C signed overflow behaviour

2019-05-12 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue36791] sum() relies on C signed overflow behaviour

2019-05-12 Thread miss-islington
miss-islington added the comment: New changeset b7e483b6d07081d5f81860258e95785975a7cbf8 by Miss Islington (bot) in branch '3.7': bpo-36791: Safer detection of integer overflow in sum(). (GH-13080) https://github.com/python/cpython/commit/b7e483b6d07081d5f81860258e95785975a7cbf8 --

[issue36791] sum() relies on C signed overflow behaviour

2019-05-12 Thread miss-islington
Change by miss-islington : -- pull_requests: +13172 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue36791] sum() relies on C signed overflow behaviour

2019-05-12 Thread Mark Dickinson
Mark Dickinson added the comment: Can this be closed, or does the fix need to be backported? -- ___ Python tracker ___ ___ Python-b

[issue36791] sum() relies on C signed overflow behaviour

2019-05-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 29500737d45cbca9604d9ce845fb2acc3f531401 by Serhiy Storchaka in branch 'master': bpo-36791: Safer detection of integer overflow in sum(). (GH-13080) https://github.com/python/cpython/commit/29500737d45cbca9604d9ce845fb2acc3f531401 --

[issue36791] sum() relies on C signed overflow behaviour

2019-05-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I tested few cases (all positive, all negative, mixed), and did not found any performance difference after this change. ./python -m perf timeit -s "a = list(range(10**4))" -- "sum(a)" ./python -m perf timeit -s "a = [-i for i in range(10**4)]" -- "sum(a)" .

[issue36791] sum() relies on C signed overflow behaviour

2019-05-03 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +12995 stage: -> patch review ___ Python tracker ___ ___ Python-bug

[issue36791] sum() relies on C signed overflow behaviour

2019-05-03 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : sum() assumes that an arithmetic operation on signed longs will wrap modulo 2**(bits_in_long) on overflow. However, signed overflow causes undefined behaviour according to the C standards (e.g., C99 6.5, para. 5), and gcc is known to assume that signed