[Chicago] Python/Mono slapdown [no pycon content]

Ian Bicking ianb at colorstudy.com
Fri Mar 7 00:38:37 CET 2008


Martin Maney wrote:
>>> Hard (impossible?) to make cons-free structures. For this particular
>>> program, this is a killer.
>> You have to use Numeric.
> 
> I know enough to think "maybe Numeric could do something here".  But to
> be honest I don't know if I'd have pursued that vague thought, since I
> tend to think that Numeric is for, well, numeric (viz, floating point)
> stuff.  At least that's how I remember it being described...

It's basically for holding lots of data and handling it efficiently. 
It's used a lot by PyGame, for instance, because things like bitmaps fit 
that model.  Anytime you have to efficiently handle lots of numeric data 
(including bytes and ints) it is handy, as it stores them efficiently 
and only turns them into Python objects on demand.

Like, imagine a list of 4-byte integers.  You can store that linearly in 
memory with no overhead, but they aren't Python objects, and don't even 
fit into any Python model of information (well, except maybe using 
buffers or arrays).  But you can create a wrapper that acts like a list, 
and creates Python integers from those bytes in memory on demand. 
That's what Numeric does.

I also think with buffer or array, and the struct module, you can do 
this on your own.

>>> "enum Foo { Bar, Baz, Beep }" is just much nicer than "(Bar, Baz,
>>> Beep) = range (oh-how-many-elements-again?)"
>> There's an enum library that handles this reasonably (the range thing is 
>> indeed lame).
> 
> I have to admit that I could sympathize with him if he replied to the
> effect that chasing around after third party libraries didn't give him
> a warm and fuzzy feeling.  BTW, Google found a bewildering assortment
> of things for "Python enum" - which one did you have in mind?

The one on pypi: http://pypi.python.org/pypi/enum/0.4.3

   Ian


More information about the Chicago mailing list