Skip to content

Instantly share code, notes, and snippets.

View mattip's full-sized avatar

Matti Picus mattip

  • Quansight Labs
View GitHub Profile
@mattip
mattip / sympy_integrate.md
Created November 9, 2026 14:01
PyPy and the sympy benchmarks

On speed.pypy.org there are two sympy benchmarks that peak out at over 2x CPython. Here is what helped:

  • more iterations. The JIT is working out what to optimize, it just takes a while to do it
  • (the mirror image) making tracing more eager.

So by running the benchmark with both those, we get quite close to CPython

PYTHONPATH=benchmarks/lib/sympy ./pypy3.12-c --jit trace_eagerness=20 \
    benchmarks/own/bm_sympy.py --benchmark integrate -n 300 | datamash median 1 sstdev 1
@mattip
mattip / diff.md
Created October 1, 2026 06:14
Theory on 32-bit crashes

The theory is that allocation is reentrant durning gc collection. This adds detectors for both the low-level allocator which will emit a fatalerror if a reentrant call is dicovered at a point in the middle of the allocation dictionary update, and a detector for dropped gc hook signals

diff --git a/extra_tests/test_gc.py b/extra_tests/test_gc.py
index 5513131ad1..accf9a255b 100644
--- a/extra_tests/test_gc.py
+++ b/extra_tests/test_gc.py
@@ -15,6 +15,13 @@ def test_memory_doesnt_jump_during_sweeping():
@mattip
mattip / quansight.com-migration.md
Last active August 19, 2026 20:21
Plan quansight.com migration

quansight.com migration notes

Source data

I have a scrape of quansight.com with two kinds of content:

  • pages.json (29 pages) and posts.json (58 posts) — WordPress REST API dumps (title, slug, date, content.rendered, ...). This is the real extraction source. Re-fetch with:
@mattip
mattip / sys.monitoring.md
Created July 26, 2026 11:20
sys,monitoring plan

Plan: sys.monitoring (PEP 669) for PyPy 3.12 - created by claude AI

Status: scoping / not started. Branch: py3.12.

1. Goal

Implement CPython 3.12's sys.monitoring API so that tools built against it (coverage.py, debuggers, profilers) work correctly and with low overhead on PyPy 3.12+, and so lib-python/3/test/test_monitoring.py (1763 lines, currently untestable — the module doesn't exist) passes.

@mattip
mattip / cpython-benchmarks.sh
Last active July 21, 2026 04:16
rerunning-cpython-benchmarks
#everything runs as pypy-worker
#sudo su - pypy-worker
#To rerun CPython benchmarks:
cd ~/cpython
git checkout v3.12.13
make clean
@mattip
mattip / analysis.md
Last active May 3, 2026 10:18
Possible small optimization in PyPy's interpreter

For this benchmark pypy --jit off is 3x slower than cpython3.11

from docutils.core import publish_doctree                                                        
from docutils import nodes                                                                       
                                                                                                 
RST = """                                                                                        
Title One                                                                                        
=========                                                                                        
                                                                                                 
Paragraph with *emphasis* and **strong** text.                                                   
@mattip
mattip / migration.md
Created April 11, 2026 19:50
Plan a move from buildbot to github actions

Migration Plan: Buildbot → GitHub Actions for PyPy

Platform matrix

Platform GitHub runner Container image (source)
linux-x86-64 ubuntu-latest (hosted) ghcr.io/pypy/pypy/buildslave_x86_64 (docker/Dockerfile)
linux-x86-32 ubuntu-latest (hosted) ghcr.io/pypy/pypy/buildslave_i686 (docker/Dockerfile32)
linux-aarch64 ubuntu-24.04-arm (hosted) ghcr.io/pypy/pypy/buildslave_aarch64 (docker/DockerfileArm64)
macOS x86-64 macos-13 (hosted, Intel) none
@mattip
mattip / analyze_failures.py
Created April 1, 2026 07:52
Analyze lib-python failures
#!/usr/bin/env python3
import re
import sys
import urllib.request
BUILD_NUMBER = 11645
BASE_URL = (
"https://buildbot.pypy.org/builders/pypy-c-jit-linux-x86-64"
"/builds/{build}/steps/shell_6/logs/stdio/text"
@mattip
mattip / float_summation.md
Last active November 20, 2024 06:10
Exploring fast and accurate floating point summation

From numpy/numpy#22956

Here is some code implementing a kahan summation. It is not fast

import cffi
import numpy as np
import time

ffi = cffi.FFI()
ffi.cdef("""
@mattip
mattip / gist:7eb1c97169b00d844dff5a2f30a27d0a
Created November 1, 2024 08:36
Explore 3.11 bzip test hang in multiple threads
The problematic place in the code is in the compression, when the test does compression in many threads:
```
def testThreading(self):
# Issue #7205: Using a BZ2File from several threads shouldn't deadlock.
data = b"1" * 2**20
nthreads = 2
with BZ2File(self.filename, 'wb') as f:
def comp():
for i in range(5):
# f.write(data) # original test does this, change for debugging