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

Dieter Maurer dieter at handshake.de
Fri Oct 21 14:48:30 EDT 2005


Chris Withers wrote at 2005-10-21 15:17 +0100:
>Tim Peters wrote:
>> You found ZODB.utils, which was a sensible place to look.  I don't really
>> understand how you found ZODB.utils but didn't manage to find p64, because
>> p64 is the first function in the file.
>
>Because its name means nothing to me...
>
>>>I guess p64 needs documenting,
>> 
>> I think its docstring is reasonably clear:
>> 
>>     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 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".


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).


-- 
Dieter


More information about the ZODB-Dev mailing list