[Numpy-discussion] Optimizing a pure Python Workaround

Ian Mallett geometrian at gmail.com
Mon Jul 13 19:11:13 EDT 2009


Hello,

I have some code that makes vertex buffer object terrain.  Because the setup
for this (a series of triangle strips) is a bit clunky, I just implemented
the tricky parts in Python.

The code works, but it's slow.  How should I go about optimizing it?

Thanks,

Ian

size = [#int_something,#int_something_else]
fsize = map(float,size)
array = []
for x in xrange(size[0]):
    for y in xrange(size[1]):
        array.append(np.array([ x   /fsize[0],y/fsize[1],0.0],"f"))
        array.append(np.array([(x+1)/fsize[0],y/fsize[1],0.0],"f"))
array = np.array(array)
#"array" is the final product.  I need this final product generated more
quickly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090713/53ec1570/attachment.html>


More information about the NumPy-Discussion mailing list