Skip to content

Instantly share code, notes, and snippets.

# before
def my_decorator(f):
def wrapper(*args, **kwds):
print('Calling decorated function')
return f(*args, **kwds)
return wrapper
# but why not
def my_decorator(f)(*args, **kwds):
print('Calling decorated function')
import pty
import time
import os
import termios
import signal
import sys
import traceback
import threading
if len(sys.argv) > 1:
package main
var x interface{ f() }
type A struct {
fp func()
}
func (a A) f() { a.fp() }
#!/usr/bin/env python
import os
import time
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
INTERVAL = 1
COMM_SIZE = (10,)
@nelhage
nelhage / llama.json
Last active January 3, 2021 18:34
Llama CF template
{
"Parameters": {
"ObjectStoreBucket": {
"Type": "String",
"Description": "A pre-existing S3 bucket to use for llama's object store"
},
"ObjectStorePrefix": {
"Type": "String",
"Description": "A prefix in $ObjectStoreBucket under which to store objects",
"Default": "/",
# BoringSSL build times, Pixelbook
# `make -j5`, local compiler
real 2m40.180s
user 8m37.189s
sys 1m21.565s
# `ninja -j6`, local
real 2m35.987s
user 7m53.337s
sys 1m14.439s
b1:
%x1 = 1
jmp b3
b2:
%x2 = 2
jmp b3
b3:
%x3 = phi [b1, %x1], [b2, %x2]
@nelhage
nelhage / .gitignore
Last active May 26, 2020 07:04
cuviper/probe bug report
/target
[nelhage@monolithique:~/code/alexbench]$ clang-11 -O1 -S -c -emit-llvm overflow_2.c
[nelhage@monolithique:~/code/alexbench]$ opt-11 --opt-bisect-limit=137 -O2 -S overflow_2.ll 2>/dev/null | opt-11 -O2 -S -o overflow_2_opt.ll
[nelhage@monolithique:~/code/alexbench]$ cat overflow_2_opt.ll
; ModuleID = '<stdin>'
source_filename = "overflow_2.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: nofree nounwind uwtable
define dso_local { i8*, i64 } @f1_overflow() local_unnamed_addr #0 {
@nelhage
nelhage / Cargo.toml
Last active May 4, 2020 03:19 — forked from alex/Cargo.toml
vectorized contains4 implementation in rust
[package]
name = "f"
version = "0.1.0"
authors = ["Alex Gaynor <alex.gaynor@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
packed_simd = "0.3"