From: Jonathan Hartley <tartley@ta...>  20101119 01:20:20

On 12/11/2010 16:29, Christopher Barker wrote: > On 11/11/10 11:48 PM, Jonathan Hartley wrote: >> What is the fastest way in python to build a c array from a list of >> tuples of floats? The context: my Python code pass arrays of 2D vertices >> to OpenGL. > > This seems like an obvious use for numpy: > >> points = [(random(), random()) for _ in xrange(1000)] > > def array_numpy(points): > return np.array(points, dtype=float32) > > And you can save the overhead of the function call, since it's a > oneliner anyway. Of course, if you're using numpy, you probably never > would have had all those points in tuples in the first place  you'd > just use numpy arrays from the start. Thanks for this. I'm trying out the numpy approach now. Jonathan  Jonathan Hartley Made of meat. http://tartley.com tartley@... +44 7737 062 225 twitter/skype: tartley 