Get C speed in Python using “gmpy” module!!!

125 views
Skip to first unread message

MM.Brian

unread,
Jan 5, 2010, 7:58:24 AM1/5/10
to sharifpython88
Salam :)
module gmpy shamele barkhi az function haye porkarborde riaZ tu
pythone va farghesh ba module math dar sorate besiar balashe (albate
kheyli az tebe haye matho nadare)
masalan man sorate mohasebeye 100000! ro ba 3 ravesh emtahan kardam va
be natayeje heyratavari reCdam!:
math.factorial(10**5) > 19.9129998684 seconds!
using reduce function > 20.1870000362 seconds!
gmpy.fac(10**5) > 0.0780000686646 seconds!!!!! (255 times
faster than math.factorial!!!)

barkhi az functionaye bedardbokhor va jalebe in module ebaratand az:
>>> gmpy.is_prime #for prime testing
>>> gmpy.next_prime #returns the next prime after a given number
>>> gmpy.is_square #for perfect squre testing
>>> gmpy.is_power #for perfect power testing!
>>> gmpy.fib #returns the n-th Fibonacci number
>>> gmpy.gcd #returns the greatest common divisor of two numbers
>>> gmpy.lcm #returns lower common multiple of two numbers
>>> gmpy.comb #C(n,k)

Download link: http://groups.google.com/group/sharifpython88/web/gmpy-1.11rc1.win32-py2.6.rar
Source: http://code.google.com/p/gmpy/
More info @ http://gmpy.sourceforge.net/
Best :)

zeynab razzagh panah

unread,
Jan 5, 2010, 9:14:49 AM1/5/10
to sharifp...@googlegroups.com
WOW...
seriously dude... you're a freakin' LIFESAVER!!!!

zeynab razzagh panah

unread,
Jan 5, 2010, 10:55:13 AM1/5/10
to sharifp...@googlegroups.com
here's another link for the ones using win 64bit:  http://gmpy.googlecode.com/files/gmpy-1.11rc1.win-amd64-py2.6.exe
shouts out to MM.Brian for the great proposal.

zeynab razzagh panah

unread,
Jan 5, 2010, 11:23:08 AM1/5/10
to sharifp...@googlegroups.com
*Edit: http://www.4shared.com/file/188967962/a1898075/gmpy-111rc1win-amd64-py26.html
seems like the other one doesn't work for the IPs from our country...(stupid google...) 
just follow the link above and you should be OK.
Reply all
Reply to author
Forward
0 new messages