speeding up Python script
Tomasz Rola
rtomek at ceti.pl
Wed May 18 07:54:24 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wed, 18 May 2005, Luis P. Mendes wrote:
> Hi,
>
> I have a 1000 line python script that takes many hours to finish. It is
> running with six inside 'for' loops.
>
> I've searched the net for ways to speed up the proccess.
>
> Psyco improves performance around 3% in this case which is not good enough.
>
> How can I dramatically improve speed?
>
> I tried to find some tool that converts Python to C automatically but
> couldn't. As I don't know C, I think that weave and PyInline for
> example are out of the solution.
>
> I'm using Linux.
Maybe this will help you, since you didn't tell what is your python
version, I've seen 2-2.5x speed increase by just replacing 2.1 with psyco
by 2.3 with psyco.
=> (1003 3): cat bzz2_* | /usr/bin/time python2.3 somescript.py '2.ada miala mak.ba' | wc -c
psyco.full start
psyco.full end
7.48user 0.03system 0:07.58elapsed 99%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (436major+358minor)pagefaults 0swaps
1064960
=> (1003 4): cat bzz2_* | /usr/bin/time somescript.py '2.ada miala mak.ba' | wc -c
psyco.full start
psyco.full end
18.27user 0.03system 0:19.00elapsed 96%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (357major+183minor)pagefaults 0swaps
1064960
Regards,
Tomasz Rola
- --
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:tomasz_rola at bigfoot.com **
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv
iQA/AwUBQoss9xETUsyL9vbiEQLMDACeKCnkwsegr6pgMEAMvTC3ip0ZCxkAoLJa
t/LrsGlMwg0Xu7gJ8hcI2ywK
=1aHL
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list