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
import functools | |
from collections import OrderedDict | |
class Registrar: | |
def __init__(self): | |
self.registry = OrderedDict() | |
def __call__(self, func=None, **kwargs): | |
def register(kwargs, func): | |
self.registry[func] = kwargs |
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
#include <cassert> | |
#include <cmath> | |
#include <iostream> | |
#include <tuple> | |
#include <vector> | |
#include <unordered_map> | |
struct RGB { | |
double R, G, B; | |
}; |
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
import math | |
import itertools | |
from concurrent.futures import ThreadPoolExecutor as PoolExecutor | |
#from concurrent.futures import ProcessPoolExecutor as PoolExecutor | |
def is_prime(n): | |
if n % 2 == 0: | |
return False | |
sqrt_n = int(math.floor(math.sqrt(n))) |
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
import sys | |
def coroutine(): | |
data = yield | |
while True: | |
if data: | |
print('Processing', data) | |
data = yield len(data) | |
c = coroutine() |