[Python-Dev] Octal literals

Bengt Richter bokr at oz.net
Sun Feb 5 21:28:30 CET 2006


On Sun, 05 Feb 2006 09:38:35 -0800, Josiah Carlson <jcarlson at uci.edu> wrote:

>
>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:
> >>> -0x80000000
> -2147483648L
> >>> -2147483648
> -2147483648
> >>> -(2147483648)
> -2147483648L
>
>1. If your Python code distinguishes between ints and longs, it has a
>bug.
Are you just lecturing me personally (in which case off list would be more appropriate),
or do you include the authors of the 17 files I count under <some prefix>/Lib that have
isinstance(<something>, int) in them?
Or would you like to rephrase that with suitable qualifications? ;-)

>
>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.
I respect Martin's expert knowledge and manner of communication. He said,
"Just have a look at the 'k' specifier in PyArg_ParseTuple."

Regards,
Bengt Richter



More information about the Python-Dev mailing list