[Tutor] Can I speed this up?
Kent Johnson
kent_johnson at skillsoft.com
Thu Oct 14 20:44:12 CEST 2004
The import psyco can be anywhere. The psyco.bind(factorsOfInteger) has to
come after the definition of factorsOfInteger or you will get a NameError.
I've been monkeying around with a version of this, I'll post it when I get
time to write it up...the key for me was instead of isPrime() I have find
findFactor()
Kent
At 11:34 AM 10/14/2004 -0700, Dick Moores wrote:
>Kent,
>
>Thanks very much. Got psyco working, and it makes a significant
>difference. The worst "anomalie" I'd found in the 400 trillion range was
>400,000,000,092,821 = 19624679*20382499.
>After implementing a couple of your previous suggestions the time for this
>went
>from 41 to 18 seconds. And now with psyco, to 13 seconds!
>
><http://www.rcblue.com/Python/factorIntegers-forWeb-WithPsyco4.py>
>Version I first asked about is still at
><http://www.rcblue.com/Python/factorIntegers-forWeb.py>
>
>I'm still trying to re-rethink isPrime(), isPrimeSmall(), isPrimeBig()
>and factorsOfInteger().
>
>BTW I'm wondering why you said to put
>
>import psyco
>psyco.bind(factorsOfInteger)
>
>after the definition of factorsOfInteger(). I have "import time" at the
>top, above all the functions. Is this wrong (it works there) or non-standard?
>
>Dick
>
>
>Kent Johnson wrote at 08:15 10/14/2004:
>>Unzip the zip file. Copy the folder psyco-1.2/psyco into
>>Python23/Lib/site-packages. (Create site-packages if you don't already
>>have it.) Should be good to go then.
>>
>>Kent
>>
>>At 07:38 AM 10/14/2004 -0700, Dick Moores wrote:
>>>Kent Johnson wrote at 05:32 10/12/2004:
>>>>Using psyco gives a small speedup - in my limited testing, about 15%.
>>>>
>>>>Install psyco from http://psyco.sourceforge.net, then put these two
>>>>lines after the definition of factorsOfInteger:
>>>>import psyco
>>>>psyco.bind(factorsOfInteger)
>>>
>>>Sorry to be so dumb about these things, but I can't figure out how to
>>>install Psyco. I now have psyco-1.2-win-2.3.zip in my C:\Python23 folder
>>>(Win XP). I've poked around in the file but I don't see any instructions
>>>as to what to next to install Psyco. Also,
>>><http://psyco.sourceforge.net/psycoguide/index.html> doesn't help this dummy.
>>>
>>>Help, please.
>>>
>>>Dick Moores
>>>rdm at rcblue.com
>
More information about the Tutor
mailing list