Python - Our key to Efficiency

mxUID - An UID datatype

Interface ( Functions : Objects : Constants ) : Examples : Structure : Support : Download : Copyright & License : History : Home Version 0.1.0


    XXX Note: The documentation is still far from complete !!!

    This package provides a fast mechanism for generating universal identification strings (UIDs). The intent is to make these UIDs unique with high probability in order to serve as object or data set identifiers.

    A typical use lies in generating session IDs. Other areas where unique IDs play an important role are RPC-implementations, ORBs, etc.



    Error class used for package specific errors. It is a subclass of exceptions.StandardError.

Examples of Use

    Here is a very simple one:

    from mx.UID import *
    >>> uid = UID()
    >>> print uid
    >>> verify(uid)
    >>> verify(uid + '123')
    >>> timestamp(uid)
    <DateTime object for '2001-10-02 19:22:47.00' at 81cc330>

    More examples will eventually appear in the Examples subdirectory of the package.

Package Structure


    Entries enclosed in brackets are packages (i.e. they are directories that include a file). Ones without brackets are just simple subdirectories that are not accessible via import.

    The package imports all symbols from the extension module, so you only need to 'from mx import UID' to start working.


What I'd like to hear from you...

    • Comments, ideas, bug-fixes :-)

Copyright & License

History & Future

    Things that still need to be done:

    • Provide some examples.

    • Add more documentation.

    Changes from 0.1.0 to 0.2.0:

    • Moved verify() into the C extension.

    • Added (undocumented, internal) otp() API which allows applying a one-time stamp to a UID string for encryption. The function is idempotent (applying it a second time will reverse the mapping) making it ideal for encryption/decryption.

    • Added helper APIs mangle() and demangle() which encode the UID strings in a way which should make it very hard to construct valid UIDs without knowledge of the key string provided that only mangled UID strings are made public. The APIs also add noise to the UID strings to cover the internal structure (this doesn't make them more secure to analysis, though).

    • Changed the UID layout to enhance performance, esp. when using the UIDs as index strings in databases (they no longer start with the timestamp, which caused UIDs to typically differ starting at the 9th string position). The UID length also has gone down to the more computer friendly 32 byte format.

    • Reduced the maximum code length.

    • Fixed a portability bug. The mxUID_GetCurrentTime() API (taken from mxDateTime) needs some extra include files on a few platforms. Thanks to Dirk Holtwick for finding this one -- it was a simple copy&paste bug.

    Version 0.1.0 was the intial release.

© 1998-2000, Copyright by Marc-André Lemburg; All Rights Reserved. mailto:

© 2000-2001, Copyright by Software GmbH; All Rights Reserved. mailto: