A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-January/011819.html below:

[Python-Dev] Weird use of hash() -- will this work?

[Python-Dev] Weird use of hash() -- will this work? [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




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