[PYTHON MATRIX-SIG] Another problem?

Rob.Hooft@embl-heidelberg.de Rob.Hooft@embl-heidelberg.de
Fri, 16 Aug 1996 20:36:25 +0200 (MET DST)

>>>>> "JH" == Jim Hugunin <hugunin@mit.edu> writes:

 JH> Rob.Hooft@embl-heidelberg.de wrote:

 >> factor took 10.577 seconds
 >> afactor took 7.916 seconds

 JH> I'm running on a faster machine than you, so my numbers are
 JH> faster in both cases, still the relative comparision is valid.

 JH> factor took 2.708 seconds
 JH> afactor took 0.322 seconds

Your machine isn't much faster, it is the python virtual machine that
is much faster :-\. With your version on my box:

factor took  10.327 seconds
afactor took   0.475 seconds

see? I'm running on a 150MHz alpha here, so speed isn't that bad, it is
just that python is juggling 64bit entities everywhere....

 JH> Here's my new version of your afactor and asieve functions.

 JH> #Set multiples of i to be nonprime
 JH> numbers[(i*i)::i] = 0

Right. That is the key. I've been wondering how to do that without
realizing that slices like this are incredibly powerful.

BUT: there is a bug in your script: try running it with upto=999999

  IndexError: invalid slice

:-) If the bug is fixed, the behaviour is almost o(N).

BTW: I'm running on an ALPHA, and I also get a crash when combining arrays 
with long integers. "gdb" tells me we're somewhere in "PyObject_Str"....

=== Rob.Hooft@EMBL-Heidelberg.DE   http://www.Sander.EMBL-Heidelberg.DE/rob/ ==
==== In need of protein modeling?  http://www.Sander.EMBL-Heidelberg.DE/whatif/
Validation of protein structures?  http://biotech.EMBL-Heidelberg.DE:8400/ ====
== PGPid 0xFA19277D == Use Linux!  Free Software Rules The World! =============

MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org