0

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!!!

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by drone626
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.