Skip to content

Instantly share code, notes, and snippets.

View zanieb's full-sized avatar

Zanie Blue zanieb

View GitHub Profile
@zanieb
zanieb / bench.py
Created March 12, 2025 00:44
A simple calculation benchmark
def short_calcul(n):
result = 0
for i in range(1, n+1):
result += i
return result
def long_calcul(num):
result = 0
for i in range(num):
cpython-3.12> BOLT-INFO: Target architecture: x86_64
cpython-3.12> BOLT-INFO: BOLT version: <unknown>
cpython-3.12> BOLT-INFO: first alloc address is 0x
cpython-3.12> 400000
cpython-3.12> BOLT-INFO: creating new program header table at address 0x600000, offset 0x200000
cpython-3.12> BOLT-INFO: enabling relocation mode
cpython-3.12> BOLT-INFO: forcing -jump-tables=move for instrumentation
cpython-3.12> BOLT-INFO: enabling lite mode
cpython-3.12> BOLT-INFO: 0 out of 11 functions in the binary (
cpython-3.12> 0.0%) have non-empty execution profile

Converting from requirements.in and requirements.txt to pyproject.toml and uv.lock

Use the following one-liner to reformat an existing requirements.txt file as constraints:

$ uv pip compile requirements.txt --no-annotate --no-header \
    | awk '{printf("%s\"%s\",\n", (NR==1?"constraint-dependencies = [\n    ":"    "), $0)}' \
    | sed '$s/,$/\n]/'
@zanieb
zanieb / gist:84748b0ca7bff58cdfb4d0068b446d58
Created February 12, 2025 22:21
`python-build-standalone` performance 3.14.0a4 (with default interpreter) vs 3.14.0a5 (with tail call interpreter)
cpython-3.14.0a4-linux-x86_64-gnu (20250205)
cpython-3.14.0a5-linux-x86_64-gnu (20250212)
==========
Performance version: 1.11.0
Report on Linux-6.1.0-26-amd64-x86_64-with-glibc2.36
Number of logical CPUs: 12 (AMD Ryzen 5 3600)
Date: 2025-02-12
All benchmarks:
❯ uvx pyperf compare_to bolt-baseline.json bolt-all-opts.json -G
Benchmarks with tag 'apps':
===========================
Faster (2):
- 2to3: 230 ms +- 1 ms -> 223 ms +- 1 ms: 1.03x faster
- docutils: 2.22 sec +- 0.01 sec -> 2.19 sec +- 0.02 sec: 1.01x faster
Benchmark hidden because not significant (1): html5lib
❯ uvx pyperf compare_to bolt-baseline.json bolt-hugify.json bolt-cdsplit.json bolt-split-all-cold.json
Benchmarks with tag 'apps':
===========================
2to3
====
Mean +- std dev: [bolt-baseline] 231 ms +- 1 ms -> [bolt-hugify] 230 ms +- 2 ms: 1.00x faster
Mean +- std dev: [bolt-baseline] 231 ms +- 1 ms -> [bolt-cdsplit] 232 ms +- 1 ms: 1.00x slower
Mean +- std dev: [bolt-baseline] 231 ms +- 1 ms -> [bolt-split-all-cold] 231 ms +- 1 ms: 1.00x faster

On a Hetzner bare metal machine with AMD Ryzen 5 3600, 64 GB DDR4 RAM, 2 x 512 GB NVMe SSD

❯ uvx pyperf compare_to bolt-baseline.json bolt-hugify.json bolt-cdsplit.json bolt-split-all-cold.json
Benchmarks with tag 'apps':
===========================

2to3
====
ARG DEBIAN_VERSION=unstable
FROM debian:${DEBIAN_VERSION}
ARG LLVM_VERSION=20
ENV LLVM_VERSION=${LLVM_VERSION}
ARG DEBIAN_VERSION
ENV DEBIAN_VERSION=${DEBIAN_VERSION}
# Licensed under the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
<#
.SYNOPSIS
The installer for uv 0.5.0
#!/bin/sh
# shellcheck shell=dash
#
# Licensed under the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
# The version of ksh93 that ships with many illumos systems does not