[Python-Dev] Weird use of hash() -- will this work?
Martin v. Loewis
martin@mira.cs.tu-berlin.de
Thu, 18 Jan 2001 20:31:29 +0100
> Comments?
Yes, three of them:
1. To guarantee uniqueness atleast within the process, the easiest
solution would be
if using_threads:
import thread
lock=thread.allocate_lock()
_acquire = lock.acquire_lock
_release = lock.release_lock
else:
_acquire = _release = lambda:None
_cookie = time.time()
def getCookie():
global _cookie
_acquire()
_cookie+=1
result = _cookie
_release()
return result
2. Invoking [] repeatedly likely returns the an object with the same
id() when called twice in a row (i.e. with no intermediate objects
allocated in-between).
3. Why did you send this question to python-dev? python-list is more
appropriate.
Regards,
Martin