I have a simple rational number class which looks roughly like:

class Rational:
         def __init__(self, numerator,denominator):
                   self.numerator= numerator
                   self.denominator= denominator

          more functions...

but when I work with really large numbers such as the following example:

>>>a= Rational(2**64, 1)
>>>a

python crashes telling me Rational instance has no attribute numerator.

When I execute my program which uses this class I can watch the numbers grow in size at which some point they are represented like 123...89L, shortly after python will crash.

Am I pushing the limits of python ints? I am on a 64-bit intel E8400 running 64-bit Arch linux.

Thanks in advance!!!

Recommended Answers

All 3 Replies

Unable to reproduce on Linux myhost 2.6.27-11-generic #1 SMP i686 GNU/Linux
Intel(R) Core(TM)2 Duo CPU E4600 @ 2.40GHz
Python 2.5.2

class Rational:
         def __init__(self, numerator,denominator):
                   self.numerator= numerator
                   self.denominator= denominator

a=Rational(2**64,1)
print a

Works fine.

Works fine for me too:

<__main__.Rational instance at 0x023A56E8>

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32

Thanks, I found my error!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.