Skip to content

Instantly share code, notes, and snippets.

View gnprice's full-sized avatar

Greg Price gnprice

View GitHub Profile
View 00 Python timings
$ python -m timeit -v -s 'import bench_fnclass as b' 'b.as_fn()'
10 loops -> 0.000801 secs
100 loops -> 0.00851 secs
1000 loops -> 0.113 secs
10000 loops -> 7.75 secs
raw times: 7.2 7.22 7.24
10000 loops, best of 3: 720 usec per loop
$ python -V
Python 2.6.6
View bench_fnclass.py
# Times are PyPy / CPython.
# Python 2.7.0 (e837df3968a1, Mar 15 2011, 03:00:18)
# [PyPy 1.5.0-alpha0 with GCC 4.4.3] on linux2
# Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
# [GCC 4.4.5] on linux2
# The CPython is 64-bit, the PyPy 32-bit, which I hope is not
# confounding anything. Both running on the same machine.
# Times measured with
# $ $PYTHON -m timeit -n10000 -r3 -s 'import bench_fnclass as b, gc; gc.enable()' "b.$func()"
@gnprice
gnprice / sigprof.patch
Created November 19, 2012 04:11
Patch to make MRI/Ruby safe for -pg
View sigprof.patch
From 98fc9cd0b28921dc02ee4c366c96e4caeb7d8475 Mon Sep 17 00:00:00 2001
From: Greg Price <price@mit.edu>
Date: Wed, 31 Oct 2012 15:53:59 -0700
Subject: [PATCH] Suppress SIGPROF
We don't handle it well -- the exact reason is unclear, but threading
seems to trigger it -- so just squelch it.
Building with -pg is necessary for getting call-graph information with
e.g. the Linux 'perf' profiler. But -pg also causes the libc startup
@gnprice
gnprice / notes
Last active July 28, 2016 02:03
mypy on mypy, with --strict-optional
View notes
... actually, see https://paper.dropbox.com/doc/Mypy-strict-optional-UQPcKDn5VDdSXQme37o1G for much more easily-editable notes.
@gnprice
gnprice / fonts.conf
Created August 7, 2017 21:25
Noto CJK font fix
View fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
Problem: After installing the Noto fonts (on my Debian `stretch`
system, with `apt install fonts-noto`), Japanese text in my
browser ends up displayed in the "Medium" style of the font
rather than the "Regular" style. The "Medium" style is too
heavy for normal text.
View LowestUnique.sol
pragma solidity ^0.5.0;
contract LowestUnique {
uint256 ante = 0.01 ether;
enum Stage { INIT, IN_PROGRESS, END }
Stage private stage;
uint private commitDeadline;
uint private revealDeadline;
View DefaultKeyBinding.dict
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
@gnprice
gnprice / # Python nixpkgs benchmarks
Last active April 2, 2020 04:55
Python benchmarks for nixpkgs
View # Python nixpkgs benchmarks
These are benchmark results from the "pyperformance" benchmark suite:
https://pyperformance.readthedocs.io/
on CPython built with various options for optimization.
For context, including the specific optimizations involved, see:
https://github.com/NixOS/nixpkgs/pull/84072
View sample.nix
{ attr
}:
# Scaffold to build just one package with modified stdenv scripts.
#
# Dependencies come unmodified from <nixpkgs>, including the stdenv's
# toolchain. This is useful for (a) iterating quickly on changes to
# stdenv scripts (like setup.sh), and (b) more easily comparing the
# build log against a baseline, by keeping inputs' paths the same so
# that any changes caused by changes in the scripts' behavior stand out.
@gnprice
gnprice / 00-def.js
Last active June 21, 2021 22:06
Generated notifs code
View 00-def.js
/* eslint-disable */
!(function(r) {
(r.__r = o),
(r.__d = function(r, i, n) {
if (e[i] != null) {
return;
}
const o = {
dependencyMap: n,
factory: r,