[Python-Dev] Octal literals

"Martin v. Löwis" martin at v.loewis.de
Sat Feb 4 11:11:08 CET 2006

Bengt Richter wrote:
>>The typical way of processing incoming ints in C is through
>>PyArg_ParseTuple, which already has the code to coerce long->int
>>(which in turn may raise an exception for a range violation).
>>So for typical C code, 0x80000004 is a perfect bit mask in Python 2.4.
> Ok, I'll take your word that 'k' coercion takes no significant time for longs vs ints.

I didn't say that 'k' takes no significant time for longs vs ints. In
fact, I did not make any performance claims. I don't know what the
relative performance is.

> Well, I was visualizing having a homogeneous bunch of bit mask
> definitions all as int type if they could fit. I can't express
> them all in hex as literals without some processing. That got me started ;-)

I still can't see *why* you want to do that. Just write them as
hex literals the way you expect it to work, and it typically will
work just fine. Some of these literals are longs, some are ints,
but there is no need to worry about this. It will all work just

> BTW, is long mandatory for all implementations? Is there a doc that
> defines minimum features for a conforming Python implementation?

The Python language reference is typically considered as a specification
of what Python is. There is no "minimal Python" specification: you have
to do all of it.


More information about the Python-Dev mailing list