Recursion limit problems

elventear elventear at gmail.com
Fri May 11 18:17:57 EDT 2007


Hello everyone,

I am runing into recursion limit problems. I have found that the
culprit was related to the __hash__ function that I had assigned to
the objects that were added to a set.

Basically my __hash__ function is the following:

	def __hash__(self):
		out_int = 0
		for property,value in self:
			out_int ^= hash( property )^hash( value )

		return out_int

And the iterator for this object is:

	def __iter__(self):
		for property,value in self.__dict__.iteritems():
			yield property,value

After commenting the __hash__ function and using the default provided
by Python (I suppose it is based on the position in memory of the
object), the recursion limit problems went away. (This problem was
happening even after increasing the recursion limit to the maximum of
my platform, MacOSX).

I am not that versed in Python, so I don't know exactly I could do to
overcome this problem, any ideas are deeply appreciated.

Thanks!




More information about the Python-list mailing list