Skip to content

Instantly share code, notes, and snippets.

View mpkocher's full-sized avatar

M. Kocher mpkocher

View GitHub Profile
@mpkocher
mpkocher / compose_functions.py
Created March 31, 2014 16:18
compose functions in python
def compose(*funcs):
"""Functional composition
[f, g, h] will be f(g(h(x)))
"""
def compose_two(f, g):
def c(x):
return f(g(x))
return c
return functools.reduce(compose_two, funcs)

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@mpkocher
mpkocher / boiler.py
Last active March 30, 2021 02:55
MK common Python utils
# Common core utils are too small that don't warrant creating a package
from argparse import ArgumentParser, Namespace, ArgumentDefaultsHelpFormatter
import csv
import functools
import logging
import sys
from typing import Callable as F
from typing import List, TypeVar, Type, Iterator
from pydantic import BaseModel