Jython random module produces different results to cpython
Question: I'm generating some test data using a known random seed. I want to use this
data from cpython and from jython. I've found that the data is different if I
use jython (2.5.2) vs cpython.

Boiling it down to a simple test, I can see that the PRNG is giving different
results in the two implementations:

In Jython:

    
    
    Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06) 
    [Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_26
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import random
    >>> random.seed(1)
    >>> random.random()
    0.7308781974052877
    

In CPython:

    
    
    Python 2.7.2+ (default, Oct  4 2011, 20:03:08) 
    [GCC 4.6.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import random
    >>> random.seed(1)
    >>> random.random()
    0.13436424411240122
    

The test data I'm generating is reproducible within each python
implementation. Is there a way around this? Maybe I need to code my own PRNG?


Answer: There is a way around this. Both implementations include the pure-python
"WichmannHill" PRNG. It's slower but it gives the same results in both Jython
and CPython.

In my code I replaced

    
    
    random.seed(1)
    uuid += random.choice(hexdigits)
    

with

    
    
    rand = random.WichmannHill(1)
    uuid += rand.choice(hexdigits)
    

