[Python-Dev] how about adding ping's uuid module to the standard lib ?
Phillip J. Eby
pje at telecommunity.com
Tue Mar 7 17:01:00 CET 2006
More information about the Python-Dev mailing list
Tue Mar 7 17:01:00 CET 2006
- Previous message: [Python-Dev] how about adding ping's uuid module to the standard lib ?
- Next message: [Python-Dev] how about adding ping's uuid module to the standard lib ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 06:29 AM 3/7/2006 +0100, Fredrik Lundh wrote: >see subject and http://python.org/sf/1368955 > >comments ? Why can't the UUIDs be immutable, so they can be dictionary keys? Also, it would be nice if you could just call UUID() to create a generic UUID in a platform-appropriate way. PEAK's uuid module does this such that if win32all is present, you get a Windows GUID, or if you have a FreeBSD 5+ or NetBSD 2+ kernel you use the local platform uuidgen API. See e.g.: http://svn.eby-sarna.com/PEAK/src/peak/util/_uuidgen.c?view=markup and: http://svn.eby-sarna.com/PEAK/src/peak/util/uuid.py?view=markup for details. This implementation also has unit tests: http://svn.eby-sarna.com/PEAK/src/peak/util/tests/uuid.py?view=markup and has been in production use for several years now. On the other hand, Ping's implementation is a lot simpler than ours; ours does a lot of stuff to support e.g. /dev/urandom or fallback seeding, whereas Python 2.4 offers os.urandom. We also use different fallback algorithms for getting the MAC address, including a fallback to a randomly-generated address if a system one could not be obtained. Ping's version will fail if there is no way to get the address (e.g. on Windows 9X, which has no ipconfig.exe), and does not cache the address for repeated uses, making its generation of verion-1 UUIDs *very* expensive. I like the idea of having RFC-compliant UUIDs in the stdlib, but I really want immutable ones, preferably without {} in their standard string representation. And efficient use of platform-local UUID generation APIs would also be preferable. (Note that using the Windows C API for UUIDs would make it unnecessary to execute a separate program in order to get version 1 UUIDs, and the same is true for the BSD variants with a UUID API.) (In addition to the PEAK UUID implementation, OSAF's Chandler also has a compliant UUID implementation that's written entirely in C, but I haven't played with it much. I don't know whether it supports using platform APIs for generation, but it does implement hashable, immutable UUID objects.)
- Previous message: [Python-Dev] how about adding ping's uuid module to the standard lib ?
- Next message: [Python-Dev] how about adding ping's uuid module to the standard lib ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list