Converting a c array to python list

zefciu zefirek at Speacock.Pau.Apoznan.Mpl
Sat Mar 3 07:37:33 EST 2007


Russell E. Owen wrote:

> 
> It might help to have a clearer idea of why you want to do this. 
> 

I am writing a Mandelbrot fractal generator with Tkinter interface.  Now
the generation works like this - there is a loop in python which
iterates through fractal's pixels and for each of them calls a functions
which checks if it belongs to Mandelbrot set or how many iterations does
it take for this point to bail out.  Then the python function sets the
pixel's colour according to the result.

I was testing it first with python function, written rather for
readibility not speed, using the builtin complex class.  It took about
90 s to generate a 1152x864 fractal.  Then I used a c function and it
took 14 s.  When I told it to my friend (grad student of informatics) he
said "And probably 90% of the time takes calling the function".

So I think, that maybe I should put the whole loop into c code.  But as
before the function returned only one integer at every call, now it
would have to return a rather large array of integers (maybe chars would
be enough).

zefciu



More information about the Python-list mailing list