[ZODB-Dev] oids, numbers, hex and 8-byte strings

Chris Withers chris at simplistix.co.uk
Tue Oct 25 08:11:53 EDT 2005


Dieter Maurer wrote:
>>>    def p64(v):
>>>        """Pack an integer or long into a 8-byte string"""
>>
>>Yes, but for that to be meaningful, you have to know that:
>>
>>- 0xSomething is an integer or long (it read "hex number" in my head"
>>
>>- oids are 8-byte strings
>>
>>Neither of things that sit in my brain :-(
> 
> But, you knew all this. Otherwise, you would not have been
> able to implement the "oid_[un]repr" functions.

I didn't implement oid_repr. I traced the code to find that was 
generating the conflict error. I think worked back from that to end up 
with oid_unrepr. The first time I became aware of "p64" was when you 
mentioned it...

> I much prefer the "p64" over "oid_unrepr" (or was it "oid_repr"?):
> 
>   When I need it, I am hunting bugs in an interactive Python interpreter
>   session and in such a situation I like "p64" much more than
>   the three times as long "oid_unrepr".

That's fine, I'm only proposing an alias, and some more documentation...

> BTW: you did not choose your names well.
> *IF* you want an alias (I think it would not be necessary),
> choose something like "oid_tohex" and "oid_fromhex".
> 
> This tells you not only that you work with *some* representation
> but with a hexadecimal representation (there are lots of different
> ways, an "oid" can be represented).

The alias I suggested is purely to mirror that of the oid_repr function, 
and I would include it directly above of below the oid_repr function 
with bigger documentation clues for blind people like me ;-)

Does anyone have any non-pedantic reasons for not including this alias?

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the ZODB-Dev mailing list