Recursive __cmp__ in different Python versions

R

Roman Suzi

#The following Python code:

class X:
def __cmp__(self, y):
print "cmp", self, y
return cmp(self, y)

x = X()
print x < 10

# gives interesting results under different Python version.
The most common sense in the result in Python 2.4: recursion
limit reached.

Python 2.3 tries 20+ times and then give up.

Python1.5 gives segmentation fault...


Sincerely yours, Roman Suzi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top