Re: [PyOpenGL-Users] Pyopengl - slow performance using
Brought to you by:
mcfletch
From: Ian M. <geo...@gm...> - 2011-01-14 03:46:51
|
On Thu, Jan 13, 2011 at 7:45 PM, Chris Barker <Chr...@no...> wrote: > On 1/13/2011 3:17 PM, Ian Mallett wrote: > > > doing this. Python lists are just linked lists, > > > > no, they are not -- they are internally regular C arrays. > > > > But they are resizable, which implies they are either linked lists or > > array lists--because I doubt the pointers are copied over to a brand-new > > array just big enough each time a single element is added or removed. > > A bit OT, but they handle re-sizing by over allocating when appended to. > So most of the time you can append to a list without any memory > allocation or copying, but as it grows, it does need to do that once in > a while. > Right--this data structure is called an array list. You're absolutely correct that Python users should avoid it for very high performance. I usually stick with NumPy arrays for all but the most dead simple stuff. They also tend to be compatible with other packages--in particular, I've used them to tie very nicely into PyOpenGL's VBO class: my_vbo = vbo.VBO(numpy_1x3_array,'f') In fact, they seemed to be the only thing that actually did work. And, speed aside, NumPy provides some truly great functionality when it comes to working with arrays--like element-wise operations, anyone? Ian |