[Python-Dev] Access to bits for a PyLongObject
"Martin v. Löwis"
martin at v.loewis.de
Tue Mar 6 05:59:49 CET 2007
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.
Looking at the PEP, I see that a class can implement __format__.
Wouldn't it be appropriate if the long type implemented that?
Implementation-wise, I would expect that long_format already does the
bulk of what you need to do.
OTOH, also look at _PyString_FormatLong.
Regards,
Martin
More information about the Python-Dev
mailing list