[Python-Dev] Octal literals
jcarlson at uci.edu
Sun Feb 5 18:38:35 CET 2006
bokr at oz.net (Bengt Richter) wrote:
> Martin v. Lowis <martin at v.loewis.de> wrote:
> >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.
> Sorry, I apologize for putting words in your mouth.
In regards to the aesthetics and/or inconsistancies of:
1. If your Python code distinguishes between ints and longs, it has a
2. If your C extension to Python isn't using the 'k' format specifier as
Martin is telling you to, then your C extension has a bug.
3. If you are concerned about *potential* performance degredation due to
a use of 'k' rather than 'i' or 'I', then you've forgotten the fact that
Python function calling is orders of magnitude slower than the minimal
bit twiddling that PyInt_AsUnsignedLongMask() or
PyLong_AsUnsignedLongMask() has to do.
Please, just use 'k' and let the list get past this.
More information about the Python-Dev