Skip to content

Instantly share code, notes, and snippets.

View mplanchard's full-sized avatar

Matthew Planchard mplanchard

View GitHub Profile
@mplanchard
mplanchard / pytest_parametrize_product.py
Created February 18, 2018 03:55
pytest_parametrize_product
import itertools
import pytest
@pytest.mark.parametrize(
'foo, bar', itertools.product(('a', 'b'), (True, False))
)
def test_multi(foo, bar):
print(foo, bar)
@mplanchard
mplanchard / pytest_parametrize_stack.py
Created February 18, 2018 04:01
pytest parametrize stack
import pytest
@pytest.mark.parametrize('foo', ('a', 'b'))
@pytest.mark.parametrize('bar', (True, False))
def test_multi(foo, bar):
print(foo, bar)
@mplanchard
mplanchard / time_inline_v_static.py
Created January 3, 2019 14:34
Timing of Static Methods vs. Inline Functions
"""
========================================================================
Timing Static Methods vs. Inline Functions
========================================================================
A simple test to compare the overhead of calling static functions vs.
defining and calling inline functions.
At least in this experiment, static methods are ~15-20% faster. This
is of course not even considering their improvements in testability
@mplanchard
mplanchard / 2d_array.py
Created March 13, 2019 17:14
2D Array Problem
test_array = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
]
# [2][0]