Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions threads-intro/x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
import random
from optparse import OptionParser

# to make Python2 and Python3 act the same -- how dumb
def random_seed(seed):
try:
# Introduced in Python 3.2 to match legacy versions
# https://docs.python.org/3.2/library/random.html#random.seed
random.seed(seed, version=1)
except:
random.seed(seed)
random.seed(seed) # before Python 3.2 (including Python 2)
return

def time_clock():
try:
rc = time_clock()
except:
# Introduced in Python 3.3
# https://docs.python.org/3/library/time.html#time.process_time
rc = time.process_time()
except:
rc = time.clock() # before Python 3.3 (including Python 2)
return rc

#
Expand Down
11 changes: 7 additions & 4 deletions threads-locks/x86.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
import random
from optparse import OptionParser

# to make Python2 and Python3 act the same -- how dumb
def random_seed(seed):
try:
# Introduced in Python 3.2 to match legacy versions
# https://docs.python.org/3.2/library/random.html#random.seed
random.seed(seed, version=1)
except:
random.seed(seed)
random.seed(seed) # before Python 3.2 (including Python 2)
return

def time_clock():
try:
rc = time_clock()
except:
# Introduced in Python 3.3
# https://docs.python.org/3/library/time.html#time.process_time
rc = time.process_time()
except:
rc = time.clock() # before Python 3.3 (including Python 2)
return rc

#
Expand Down