Cross platform difference: Object hex address case

Tim Peters tim.one at comcast.net
Tue Feb 25 23:48:01 EST 2003


[Tim]
>>
>> Whether hex() produces lower or upper case actually depends on
>> its argument:

[Follower]
> Is that intentional?

Doubt it.  Python "short ints" are C longs, and the hex representation comes
from the platform sprintf's treatment of the %lx format code.  The platform
snprintf can't handle unbounded ints, though, so Python does hex conversion
of Python longs itself.

> Or useful?

At this stage it doesn't matter -- code undoubtedly relies on it.

>> You can write a cleverer test than that <wink>.

> I'm tempted to show how the *actual* test works, but in the end it's
> fairly inconsequential, so I won't waste anyone's time. But if
> "cleverer" means "better", how would *you* test it? (Admittedly, my
> original example didn't show the "embedded" nature of my actual usage
> of the string representation of the object.)

I can't say, because I don't know what you're actually trying to test.  In
over a decade of using Python, I've never had the slightest temptation to
test for reproducibility of memory addresses, and that's all the original
showed.

> ...
> I guess it all goes to show how cross-platform Python helps you find
> out what's really "Python" & what's not... :-)

It can be a bit of a puzzle.  If someone paid Guido to finish writing
Python's Language Reference Manual, in about 18 months you'd have an exact
accounting, but one so dense only the obsessed could understand it <wink>.






More information about the Python-list mailing list