[Jewett, Jim J] > ... > The most obvious use case is to generate unique keys > (as lisp gensym). Just noting a practical hack that's often sufficient: import sys genunique = iter(xrange(sys.maxint)).next Then each call to genunique() delivers "the next" (short) integer, and it inherits thread safety from the global interpreter lock. A similar effect can be gotten via import itertools genunique = itertools.count().next and that also inherits thread safety from the GIL. A difference is that the xrange spelling stops when it reaches sys.maxint, but the .count spelling silently wraps around to -sys.maxint-1 then (undetected overflow at the C level).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4