[Python-Dev] Tuples vs. lists
Tue, 5 Feb 2002 10:03:13 -0800 (PST)
M.-A. Lemburg wrote:
> Aahz Maruch wrote:
>> M.-A. Lemburg wrote:
>>> For the BCD stuff Aahz was talking about, I'd suggest to have
>>> a look at either arrays or cStringIO buffers.
>> cStringIO wouldn't work because I want to store ints.
> I was thinking of storing integers as chr(value) in these.
Why spend the conversion time?
>> Arrays might
>> work, but I think I'll stick with tuples because they're a bit more
>> familiar to most Pythonistas. I'm not too concerned with raw speed and
>> efficiency before I convert the code to C; remember Knuth.
> If you plan to convert this to C, why not have a look at mxNumber
> first ? It's a wrapper around GMP and provides high performance
> implementations for many numeric operations, e.g. it should be easy
> to create a BCD type using the GMP (arbitrary length) longs and an
> additional C long for the decimal point position. In fact, there's a
> GMP extension MPFR which tries to do just this.
I'm specifically implementing the ANSI BCD spec. If you want to argue
the theory of this, poke the Timbot; I think it's simpler to ensure that
I'm following the spec if I implement everything by hand. Once I really
understand what I'm doing, *then* it's time to optimize.
Note that one reason for using BCD over GMP longs (which are presumably
similar to Python longs) is speed of I/O conversion.
--- Aahz (@pobox.com)
Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
We must not let the evil of a few trample the freedoms of the many.