Renting CPU time for a Python script
Andreas Kostyrka
andreas at kostyrka.priv.at
Thu Jul 25 09:00:34 EDT 2002
More information about the Python-list mailing list
Thu Jul 25 09:00:34 EDT 2002
- Previous message (by thread): Renting CPU time for a Python script
- Next message (by thread): Dpulicating "class Foo:" in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am Sam, 2002-07-20 um 22.16 schrieb Zachary Bortolot: > Hi Fernando, > > Thanks for your very informative post! Unfortunately the bottleneck > in my program lies with the PIL extension since I have to perform a > lot of putpixel and getpixel operations, which are quite expensive in Well, there are certain Python optimizations you could try: instead of an inner loop like this: for i in xrange(100): img.putpixel((i,i),1) use this: pp=img.putpixel for i in xrange(100): pp((i,i),1) Basically python function calls are painful slow for things like putpixel. Try to move more data per call. Either get your data into python with img.getdata (if I recall correctly) split it up into a list and manipulate it in python, or manipulate the data directly in C. Best regards, Andreas Kostyrka
- Previous message (by thread): Renting CPU time for a Python script
- Next message (by thread): Dpulicating "class Foo:" in C
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list