A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2003-August/037425.html below:

[Python-Dev] Caching tuple hashes

[Python-Dev] Caching tuple hashes [Python-Dev] Caching tuple hashesGuido van Rossum guido at python.net
Mon Aug 4 14:11:24 EDT 2003
On Mon, Aug 04, 2003 at 06:14:15PM +1000, Andrew Bennetts wrote:
> 
> * Tuples can contain badly-behaved mutables, e.g.:
> 
> >>> class X:
> ...     x = 1       
> ...     def __hash__(self):    
> ...         return self.x 
> ... 
> >>> x = X()
> >>> t = (x,)
> >>> hash(t)
> -1660579480
> >>> X.x = 2
> >>> hash(t)
> -1660579477

No, that's not a reason not to do this.  The problem is the responsibility
of class X; a tuple can assume that objects have constant hashes (since
dict lookup also makes this assumption).

--Guido van Rossum

More information about the Python-Dev mailing list

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