Skip to content

Instantly share code, notes, and snippets.

@lopuhin
lopuhin / sort.py
Created January 12, 2014 18:03
Benchmarking different sort methods against built-in sort on 1M random 32-bit integers (radix sort wins over built-in, and naive intra-sort is less than 2x slower)
# encoding: utf-8
import time
import math
import random
__help__ = '''
Benchmarking different sort methods against built-in sort
on 1M random 32-bit integers
@lopuhin
lopuhin / gist:5041302
Created February 26, 2013 19:25
stack-based emulation of recursive fibonacci function - turns out it is slower in pypy and cpython
def fib_rec(n):
if n <= 2:
return 1
else:
return fib_rec(n - 1) + fib_rec(n - 2)
def fib_stack(n):
value_stack, op_stack = [], [n]
while True:
@lopuhin
lopuhin / gist:4046920
Created November 9, 2012 17:13
Stack of PyPy executing jit-ed code
Obtained 3 stack frames.
0 pypy-c 0x000000010ebaa8ed statprof_print_trace + 29
1 ??? 0x0000000000000000 0x0 + 0
2 pypy-c 0x000000010deada68 pypy_g_execute_token__star_2 + 136
@lopuhin
lopuhin / download.filenames.log
Created February 23, 2012 13:44
Script to put youtube-downloaded videos for unit-1 of cs373 in correct order
Uqt_pRbR8rI.mp4
31xZhj2uPr4.mp4
n1EacrqyCs8.mp4
6tV5NY1HoNA.mp4
IZC33Tmy8Lo.mp4
ysebYA6tDZ4.mp4
_sAkAALHyEg.mp4
e21oU80gwWc.mp4
nsSvTTA0p8E.mp4
UFcTLCttNRI.mp4