mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Use a proper multiset for progression items
This can cut generation times in half in some cases
This commit is contained in:
16
_vendor/collections_extended/_util.py
Normal file
16
_vendor/collections_extended/_util.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""util functions for collections_extended."""
|
||||
|
||||
|
||||
def hash_iterable(it):
|
||||
"""Perform a O(1) memory hash of an iterable of arbitrary length.
|
||||
|
||||
hash(tuple(it)) creates a temporary tuple containing all values from it
|
||||
which could be a problem if it is large.
|
||||
|
||||
See discussion at:
|
||||
https://groups.google.com/forum/#!msg/python-ideas/XcuC01a8SYs/e-doB9TbDwAJ
|
||||
"""
|
||||
hash_value = hash(type(it))
|
||||
for value in it:
|
||||
hash_value = hash((hash_value, value))
|
||||
return hash_value
|
||||
Reference in New Issue
Block a user