Skip to content

Instantly share code, notes, and snippets.

CPython Dev in Residence

Łukasz Langa ambv

CPython Dev in Residence
View GitHub Profile
Runs PBTs on `bytes.count` and `bytes.find`. Also confirms results match Python 3.9.
How to use:
- build CPython 3.11 from source
- run ./python.exe -m ensurepip
- run ./python.exe -m pip install hypothesis
- run ./python.exe # this file
Note: `MAX` value below generates tests that on my machine execute between

Python 3.8.10, 3.9.5, and 3.10.0b1 are now available

This has been a very busy day for releases and on behalf of the Python development community we're happy to announce the availability of three new Python releases.

Python 3.10 is now in Beta

Python 3.10 is still in development. 3.10.0b1 is the first of four planned beta release previews. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects to support the new feature release.

We strongly encourage maintainers of third-party Python projects to test with 3.10 during the beta phase and report issues found to the Python bug tracker as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Monday, 2021-08-02). Our goal is have no ABI changes after beta 4 and as few code

ambv /
Created Mar 23, 2021
Happy Atheist Day!
from dataclasses import dataclass
from pathlib import Path
from typing import Iterable, Iterator
from PIL import Image
from rich.color import Color
from rich.console import Console, ConsoleOptions, RenderResult
from rich.segment import Segment
from import Style
View gist:98c7ebbbe8f610d1ae5f9f37a83b8a94
Sus2 027
Sus2 #5 028
DimTriad 036
Min 037
Maj 047
AugTriad 048
Sus4 057
Stack4 05A
Open4 05C
Sus #4 067
ambv /
Created Sep 25, 2020
Turns Agnes Martin paintings into numbers
#!/usr/bin/env python3
# for Disquiet 0456:
martin - converts an image with horizontal lines into JSON with a list of lists of numbers
martin <file>
martin --help
ambv / PythonFormatLinter.php
Created Sep 26, 2018
How to integrate Black with Arcanist
View PythonFormatLinter.php
final class PythonFormatLinter extends ArcanistFutureLinter {
public function getLinterName() {
return 'BLACK';
protected function getFuturesLimit() {
return 8;
ambv / tokenize.diff
Last active Apr 23, 2018
Unified diff between Lib/ and Lib/lib2to3/pgen2/
View tokenize.diff
--- Lib/ 2018-04-22 17:33:48.000000000 -0700
+++ Lib/lib2to3/pgen2/ 2018-04-22 17:32:55.000000000 -0700
@@ -31,14 +31,15 @@
import itertools as _itertools
import re
import sys
-from token import *
+from .token import *
cookie_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
ambv / config.cson
Created Jan 7, 2017
File-type specific Atom configuration
View config.cson
'softWrap': true
'tabLength': 4
'preferredLineLength': 72
ambv /
Created Dec 20, 2016
Demonstrates how `ignore = ` overrides the default ignore list, implicitly re-enabling optional warnings in bugbear. Note the line "Overriding default value of". Change bugbear version to 16.12.2 to see the workaround in action (note the line "Optional warning B950").
#!/bin/bash -e
# Create the environment
rm -rf .v # remove old stuff if present
python3 -m venv .v
source .v/bin/activate
cd .v
pip install flake8==3.2.1
pip install flake8-bugbear==16.12.1 # the newer version works around the issue
ambv /
Last active Mar 10, 2017
Defensive programming for unhandled errors. Add this to preexec_fn= in your subprocess calls.
import ctypes
import sys
import signal
def ensure_dead_with_parent():
"""A last resort measure to make sure this process dies with its parent.
Defensive programming for unhandled errors.
if not sys.platform.startswith('linux'):
return # not supported on OS X, Windows, etc. Use process groups.