[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-03-09 Thread Eric Martin
Eric Martin added the comment: Thank you for letting us know, I am actually not surprised the issue would bugger you and you would change your mind... Thinking further about it and experimenting further, I thought it might not be such an edge case and there could be a significant cost in

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-03-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: I've had misgivings about this and will revert the change for Python 3.10. Usually, it is safe for sets to implement whatever has been battle-tested with dicts, but sets should aspire to do better for alternating deletions and re-additions of the same

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-11 Thread Eric Martin
Eric Martin added the comment: Many thanks Raymond for these insights and thorough explanations, I appreciate it very much. Your conclusions are of course most reasonable. For me, I cannot say that it is a real issue in practice. I have teaching notes in which I illustrate with plots the

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Addenda [reposted to fix a premature submission]. Top use cases for sets (roughly in order of commonality): 1. Eliminate duplicates from an iterable input and loop over the result. 2. Store elements in a set just once but do many membership tests. 3.

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- Removed message: https://bugs.python.org/msg386847 ___ Python tracker ___ ___ Python-bugs-list

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Addenda. Top use cases for sets (roughly in order of commonality): 1. Eliminate duplicates from an iterable input and loop over the result. 2. Store elements in a set just once but do many membership tests. 3. Perform data analysis on multiple sets using

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-11 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: This only affects the contrived case of adding and removing exactly the same element in a tight loop, when the set is large. Optimizing that one corner case came at the expense of all other cases. The code is now simpler and slightly faster than

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-10 Thread Dennis Sweeney
Dennis Sweeney added the comment: I bisected the change to here: https://github.com/python/cpython/pull/19881 commit 3dd2157febae5087cad24f69b6de9cbd13cd Author: Raymond Hettinger Date: Sun May 3 04:51:05 2020 -0700 Simplify set entry insertion logic. (GH-19881) """Dictionaries

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-10 Thread Zachary Ware
Zachary Ware added the comment: Can reproduce on Linux: $ for python in /usr/bin/python3.? /usr/local/bin/python3.? do $python -VV $python -m timeit -r 10 -n 100_000 -u usec -s 'S = set(range(10_000))' 'S.remove(5000);S.add(5000)' done Python 3.8.5 (default, Jul 28 2020, 12:59:40)

[issue43198] Operations on sets more than hundred times less efficient with python3.9 than with previous versions

2021-02-10 Thread Eric Martin
New submission from Eric Martin : Run on a MacBook Pro (15-inch, 2019) 2.3 GHz 8-Core Intel Core i9 16 GB 2400 MHz DDR4 Python 3.8.7 (default, Dec 24 2020, 19:07:18) [Clang 12.0.0 (clang-1200.0.32.27)] on darwin Type "help", "copyright", "credits" or "license" for more