[Python-Dev] Access to bits for a PyLongObject
nmm1 at cus.cam.ac.uk
Tue Mar 6 11:19:04 CET 2007
=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <martin at v.loewis.de> wrote:
> Eric V. Smith schrieb:
> > I'm working on PEP 3101, Advanced String Formatting. About the only
> > built-in numeric formatting I have left to do is for converting a
> > PyLongOjbect to binary.
> > I need to know how to access the bits in a PyLong.
> I think it would be a major flaw in PEP 3101 if you really needed it.
> The long int representation should be absolutely opaque - even the
> fact that it is a sign+magnitude representation should be hidden.
Well, it depends on the level for which PEP 3101 is intended. I had
the same problem, and was pointed at _PyLong_AsByteArray, which was
all I needed. In my case, going though a semi-generic formatter
would not have been an acceptable interface (performance).
However, if PEP 3101 is intended to be a higher level of formatting,
then I agree with you. So I have nailed my colours firmly to the
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email: nmm1 at cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679
More information about the Python-Dev