Skip to content

Instantly share code, notes, and snippets.


David Beazley dabeaz

View GitHub Profile
dabeaz /
Created Oct 17, 2019
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 -
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
dabeaz / README.txt
Created Oct 15, 2019
PyCon India 2019, Code from Keynote Presentation by @dabeaz
View README.txt
Code from PyCon India 2019 Keynote Talk
David Beazley (
This code is presented "as is" and represents what was live-coded
during my closing keynote presentation at PyCon India, Chennai,
October 13, 2009. I have made no changes to the files.
Requires: Python 3.6+, numpy, pygame
dabeaz /
Created Oct 20, 2017
Curio Benchmark of Large Data Transfer
# A Curio adaption of benchmark code at:
import struct
from time import perf_counter as clock
except ImportError:
from time import time as clock
dabeaz /
Created Sep 14, 2016
SLY (Sly Lex-Yacc) Example
# See:
from sly import Lexer, Parser
class CalcLexer(Lexer):
tokens = {
ignore = ' \t'
literals = { '=', '+', '-', '*', '/', '(', ')' }
dabeaz /
Created Jan 7, 2016
Diabolical bug involving code that behaves differently in a class decorator vs. a metaclass
def decorate(func):
print('Decorating', func.__name__)
return func
def wrap_methods(cls):
for name in vars(cls):
if name.startswith('f_'):
setattr(cls, name, decorate(getattr(cls, name)))
dabeaz /
Last active Sep 16, 2019
Live-coded examples from my PyCon Brasil 2015 Keynote
from socket import *
import asyncio
loop = asyncio.get_event_loop()
async def echo_server(address):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
dabeaz / FileUsage.ipynb
Created Mar 26, 2013
IPython Notebook Example for my Usenix ;Login: Article
View FileUsage.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
dabeaz / pystate.c
Created Feb 3, 2013
From Python-3.3 source code, Python/pystate.c. Note the comment: I have no recollection of requesting this feature, but it must have been important at the time ;-).
View pystate.c
/* Routines for advanced debuggers, requested by David Beazley.
Don't use unless you know what you are doing! */
PyInterpreterState *
return interp_head;
PyInterpreterState *