This is plain txt
--editable .
foo==1.2
bar==3.4
baz[quux]>=1.0.1
This is pip-requirements
This is plain txt
--editable .
foo==1.2
bar==3.4
baz[quux]>=1.0.1
This is pip-requirements
import random | |
import re | |
import timeit | |
import matplotlib.pyplot as plt | |
from collections import Counter | |
def sum_digits_math(n): | |
"""from https://stackoverflow.com/a/14940026/674039""" | |
r = 0 |
def duel(a, b): | |
fa = 16807 | |
fb = 48271 | |
d = 0x7fffffff | |
count1 = 0 | |
a4 = 5000000*[0] | |
b8 = 5000000*[0] | |
na = nb = 0 | |
for i in range(40000000): | |
a = (a * fa) % d |
def duel(a, b): | |
fa = 16807 | |
fb = 48271 | |
d = 0x7fffffff | |
count1 = 0 | |
a4 = [] | |
b8 = [] | |
for i in range(40000000): | |
a = (a * fa) % d | |
b = (b * fb) % d |
# timing of pkgutil and importlib.resources loaders from https://github.com/wimglenn/resources-example | |
# Python 3.8.5 on linux | |
>>> from myapp.example2 import func as pkgutil_loader | |
>>> from myapp.example4 import func as importlib_resources_loader | |
>>> timeit importlib_resources_loader() | |
392 Β΅s Β± 329 ns per loop (mean Β± std. dev. of 7 runs, 1000 loops each) | |
>>> timeit pkgutil_loader() | |
200 Β΅s Β± 230 ns per loop (mean Β± std. dev. of 7 runs, 1000 loops each) | |
>>> timeit importlib_resources_loader() |
AoC 2019 day 9 quine: 109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99 | |
0 op_offset ip=0 opcode=00109 offset=0 args=[1] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
1 op_output ip=2 opcode=00204 offset=1 args=[0] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
2 op_add ip=4 opcode=01001 offset=1 args=[100, 6, 100] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99} | |
3 op_eq ip=8 opcode=01008 offset=1 args=[100, 10, 101] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: 1, 7: 100, 8: 1008, 9: 100, 10: 16, 11: 101, 12: 1006, 13: 101, 14: 0, 15: 99, 100: 1} | |
4 op_jump_f ip=12 opcode=01006 offset=1 args=[101, 14] {0: 109, 1: 1, 2: 204, 3: -1, 4: 1001, 5: 100, 6: |
import logging | |
from collections import defaultdict | |
from collections import deque | |
# logging.basicConfig(level=logging.INFO, format=" %(message)s") | |
log = logging.getLogger(__name__) | |
# "parameter modes" | |
POSITION = 0 |
>>> import numpy as np | |
>>> import builtins | |
>>> np.random.randn(3,3) | |
array([[-0.24401213, -0.19773938, 0.47278806], | |
[-0.6083566 , -0.65160561, 0.78145811], | |
[ 0.14546934, -0.86849935, 2.07570471]]) | |
>>> np.empty((3,3)) # sign loss | |
array([[0.24401213, 0.19773938, 0.47278806], | |
[0.6083566 , 0.65160561, 0.78145811], | |
[0.14546934, 0.86849935, 2.07570471]]) |