math.pow(x,y)
casevh at comcast.net
casevh at comcast.net
Sun Jun 11 19:26:50 EDT 2006
K.S.Sreeram wrote:
> Raymond L. Buvel wrote:
> > I just tried this and it is taking an extremely long time even on a fast
> > machine with 4 Gb of RAM. Killed it after a couple of minutes.
>
> You probably tried printing the value.
>
> a = 34564323**456356 (takes just 28 seconds)
> whereas
> b = str(a) takes forever!
>
> Regards
> Sreeram
>
If you really want all 3,440,299 digits, use the DecInt module..
http://home.comcast.net/~casevh/
Using Python 2.4.3 on a 1.4Ghz Celeron, a=DecInt(34564323) ** 456356
takes 20 seconds. astr=str(a) takes just over 1 second.
With DecInt and GMPY, the running times are 6.9 seconds and 0.4 seconds
respectively.
casevh
More information about the Python-list
mailing list