Skip to content

Instantly share code, notes, and snippets.

@ericsnowcurrently
ericsnowcurrently / profile-type_new.py
Created January 14, 2025 16:49
a script to instrument and profile type_new()
from collections import namedtuple
import logging
import os
import os.path
import re
import shutil
import subprocess
import sys
import textwrap
import time
@ericsnowcurrently
ericsnowcurrently / interpreters-todo.md
Last active January 7, 2025 18:10
interpreters TODO

⭐ - important ⬆️ - high priority ⬇️ - low priority ▫️ - normal priority

📅 - old 🥚 - new ▫️- neither

🔷 - regular contributor

@ericsnowcurrently
ericsnowcurrently / workflow.md
Last active August 2, 2024 00:27
Release Locking Workflow

Some of the recent discussion on DPO and discord got me thinking about the release workflow relative to locking branches and creating temporary ones and making some PRs wait through the whole RC phase.

As a result, I've thought of various possible workflows and about what might work well. We've used at least some of these for past releases, though not all. (I don't recall which approach was used for which release.)

Here are the workflows I thought of:

3.X branch temp branch critical/docs PRs other PRs
1 stays locked --- merged by RM (3.X) wait until final
2 only locked during release --- merged by committers (3.X) wait until final
@ericsnowcurrently
ericsnowcurrently / new-runtime-api.md
Last active February 26, 2024 17:11
A rough, high-level greenfield design for the CPython runtime API

Summary:

  • C-API takes opaque context type as first arg
  • context is as specific as possible
  • separate Py_Main() from runtime initialization
  • separate global init from interpreter init
  • explicit enabling/disabling runtime components

Background Info

@ericsnowcurrently
ericsnowcurrently / pyconfig-analysis.md
Last active January 7, 2025 20:30
Analysis of Pyconfig

PyConfig API

most relevant:

  • PyConfig (struct)
  • Py_InitializeFromConfig()
  • PyInterpreterState.config
  • _PyInterpreterState_GetConfig()
  • _Py_GetMainConfig()
@ericsnowcurrently
ericsnowcurrently / gist:99e2c79281a02a407ddf1dd49bf2d321
Last active November 17, 2022 00:30
analysis of gilstate operations
_PyRuntimeState_GetThreadState()
_PyRuntime.gilstate.tstate_current <----
_PyRuntimeGILState_GetThreadState()
_PyRuntime.gilstate.tstate_current <----
_PyRuntimeGILState_SetThreadState(tstate)
_PyRuntime.gilstate.tstate_current = tstate <----
@ericsnowcurrently
ericsnowcurrently / hide_stdio.py
Last active August 19, 2020 17:23
A context manager for discarding stdout and stderr.
import contextlib
import os
import sys
try:
from io import StringIO as StdioStream
except ImportError:
from StringIO import StringIO # 2.7
class StdioStream(StringIO):
@ericsnowcurrently
ericsnowcurrently / ensure-ensurepip.py
Created February 27, 2020 00:07
A workaround for Ubuntu's ensurepip problem.
"""
This is a script for working around the lack of ensurepip in
Ubuntu's system Python installs.
See: https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1290847
An alternative is the following:
$ python3 -m venv --without-pip my-venv
$ curl https://bootstrap.pypa.io/get-pip.py
$ my-venv/bin/python3 get-pip.py
@ericsnowcurrently
ericsnowcurrently / envs-api-design.md
Last active January 16, 2020 22:49
API Shape for the Environments Discovery Component

API Shape for the Environments Discovery Component

Requirements

The environment component  API should support following:

1. Discover installed python interpreters: This includes identifying interpreter
   details like name, version, bit-ness, interpreter paths