This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' comparing speed of new dataclass | |
with standard class attributes and slots, | |
running in 3.7.0b1''' | |
# subscribe to me: https://www.youtube.com/user/gjenkinslbcc?sub_confirmation=1 | |
# I recommend reading PEP557: https://www.python.org/dev/peps/pep-0557/ | |
# this code at gist: http://bit.ly/slotsVdatclass | |
from dataclasses import dataclass | |
from timeit import timeit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gen sequence i.e. "1,3,5-7,9" > [1,3,5,6,7,9] | |
def seq_gen(s): | |
for item in s.split(','): | |
if '-' in item: | |
a, b = map(int, item.split('-')) | |
for i in range(a,b+1): | |
yield i | |
else: | |
if len(item): | |
yield int(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hexgame.py: to learn the hex digits for binary patterns | |
# written to run in python 2.7 and 3+ | |
# Subscribe: https://www.youtube.com/user/gjenkinslbcc?sub_confirmation=1 | |
from __future__ import division, print_function | |
from random import randrange | |
from time import time | |
import sys | |
hex_digits = '0123456789ABCDEF' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# elapsed timer: as generator | |
# Youtube subscribe link: https://goo.gl/ZgZrZ5 | |
# Gerry Jenkins | |
import time | |
class ElapsedTime(): | |
def __init__(self): | |
# store only start time |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder