On Sun, 05 Feb 2006 09:38:35 -0800, Josiah Carlson jcarlson@uci.edu wrote:
bokr@oz.net (Bengt Richter) wrote:
Martin v. Lowis martin@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
- 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? ;-)
- 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