Skip to content

Instantly share code, notes, and snippets.

@naftaliharris
naftaliharris / transitivity.py
Last active August 29, 2015 14:05
Finding intransitive subclass relationships in python
"""
transitivity.py
Author: Naftali Harris
Run this in a clean virtualenv to only find intransitive triples in the stdlib.
"""
import pkgutil
import inspect
import collections
@naftaliharris
naftaliharris / trypy
Last active January 2, 2016 09:39
An enhancement to the "python" executable that automatically launches you into a debugger if your code throws an exception.
#!/bin/bash
# An enhancement to the "python" executable that automatically launches you into the python debugger on error.
#
# Use it like you would the "python" executable, for example:
# $ trypy somefile.py
# or
# $ trypy somefile.py arg1 arg2
#
# EXAMPLE:
/* Modified slightly from https://github.com/naftaliharris/lazysort */
int partition(LSObject *ls, int left, int right) {
PyObject **ob_item = ls->xs->ob_item; /* The array to be sorted */
int piv_idx = pick_pivot(ls, left, right);
PyObject *pivot = ob_item[piv_idx];
SWAP(left, piv_idx);
int last_less = left;
/* Invariant: last_less and everything to its left is less than