Operation "element in set" never returns
See original GitHub issueBug: After a series of add and remove operations on a set in nopython mode the operation “in set” does not return and gets stuck at 100% CPU load.
Isolated code example:
import numba as nb
@ nb.njit()
def problem():
# init
openSet = set()
openSet.add((0, 0))
openSet.add((1, 0))
openSet.add((2, 0))
openSet.add((3, 0))
openSet.add((4, 0))
openSet.add((5, 0))
openSet.add((6, 0))
openSet.add((7, 0))
openSet.add((8, 0))
openSet.remove((2, 0))
openSet.add((2, 1))
openSet.remove((2, 1))
openSet.remove((4, 0))
openSet.add((5, 1))
openSet.add((4, 1))
openSet.remove((7, 0))
openSet.add((8, 1))
openSet.add((7, 1))
openSet.add((6, 1))
openSet.remove((8, 0))
openSet.remove((1, 0))
openSet.remove((0, 0))
openSet.remove((5, 0))
openSet.remove((6, 0))
openSet.remove((3, 0))
openSet.remove((7, 1))
openSet.add((8, 2))
openSet.add((7, 2))
openSet.add((6, 2))
openSet.remove((8, 1))
openSet.remove((6, 1))
openSet.add((5, 2))
openSet.remove((4, 1))
openSet.add((4, 2))
openSet.remove((5, 1))
openSet.remove((6, 2))
openSet.add((7, 3))
openSet.add((6, 3))
openSet.add((5, 3))
openSet.remove((7, 2))
openSet.add((8, 3))
openSet.remove((8, 2))
openSet.remove((4, 2))
openSet.add((4, 3))
openSet.add((3, 3))
openSet.remove((5, 2))
openSet.remove((7, 3))
openSet.add((8, 4))
openSet.add((7, 4))
print('About to check (6,4) in openSet')
return (6, 4) in openSet
if __name__ == "__main__":
print(problem())
print('DONE')
The code gets stuck with numba 0.52.0 with Python 3.8.5 on Ubuntu 20.04.1 LTS x86_64.
However, @esc on gitter.im also confirmed that the issue persists on OSX.
Isolated code example: https://github.com/icezyclon/astart-pathfinding/blob/main/isolated.py Original code example (from A* search): https://github.com/icezyclon/astart-pathfinding/blob/main/problem.py
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:40 (22 by maintainers)
Top Results From Across the Web
How to retrieve an element from a set without removing it?
In python 3 keys() is an O(1) operations, so yay! However, it no longer returns a list object, it returns a set-like object...
Read more >Sets - Ada Resource Association
A set never contains two or more equivalent elements. The length of a set is the number of elements it contains.
Read more >A.18.7 Sets
A set never contains two or more equivalent elements. The length of a set is the number of elements it contains.
Read more >Python Sets Tutorial: Set Operations & Sets vs Lists - DataCamp
Discover Python Sets. Understand the difference between sets vs lists. Find Python set operations and code examples today!
Read more >5.1: Sets and Operations on Sets - Mathematics LibreTexts
We have used logical operators (conjunction, disjunction, negation) to form new statements from existing statements. In a similar manner, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@stuartarchibald and I never got to the bottom of this fully. But we are certain there is a bug present, so I will re-label thhis accordingly.
The worst case, only happens under the special circumstances, if the set contains only in-use or deleted slots. If the load on the set is low, the runtime will be O(1) yes, since only a hash is needed to lookup an element.