Skip to content

Instantly share code, notes, and snippets.

maybe:python-sibilant siege$ sibsampl timeit --of 1000 --times 1000
calculating fibonacci of 1000
answer is 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875
maximum recursion depth exceeded in comparison
maximum recursion depth exceeded
fibonacci with TCR over 1000 loops -> 0.6279 seconds (0.26% runtime)
fibonacci with TCO over 1000 loops -> 0.9989 seconds (0.41% runtime)
fibonacci no TC over 1000 loops -> 0.0000 seconds (0.00% runtime)
fibonacci LRU cache over 1000 loops -> 0.0000 seconds (0.00% runtime)
fibonacci loop over 1000 loops -> 0.8034 seconds (0.33% runtime)
@obriencj
obriencj / build_class.py
Created May 6, 2018 13:24
building classes in python
def sample_1(parent=object):
class Sample(parent):
def __init__(self, val=None):
self.value = val
return Sample
def sample_2(parent=object):
=== Sample2 class code ===
Name: Sample
Filename: build_class.py
Argument count: 0
Kw-only arguments: 0
Number of locals: 0
Stack size: 4
Flags: 0x0
Constants:
0: 'sample_2.<locals>.Sample'
@obriencj
obriencj / Containerfile
Last active February 19, 2024 18:33
tiny static native container
# This is a simple example representing a statically linked executable
# embedded in the smallest possible container
FROM gcc:latest as BUILD
WORKDIR /build
RUN gcc -x c -static -o hello - <<EOF
#include <stdio.h>
@obriencj
obriencj / work
Last active March 21, 2024 21:30
#! /bin/bash
# SSH Control and Proxy wrapper
#
# Expects there to be host configuration alias in ~/.ssh/config that
# matches the name of this script.
#
# Author: Christopher O'Brien <obriencj@gmail.com>
# License: GPLv3