Skip to content

Instantly share code, notes, and snippets.

Avatar

Brett Cannon brettcannon

View GitHub Profile
View stdlib_modules.json
{
"__future__": [],
"_xxsubinterpreters": [],
"abc": ["_abc", "_py_abc"],
"aifc": [],
"antigravity": [],
"argparse": [],
"array": [],
"ast": ["_ast"],
"asynchat": [],
@brettcannon
brettcannon / pow_test.py
Created Aug 23, 2020
Demonstration of how **= does not follow the data model appropriately
View pow_test.py
class PowTest:
def __init__(self, name):
self.name = name
def __ipow__(self, _):
print(f"{self.name}.__ipow__")
return NotImplemented
def __pow__(self, _):
print(f"{self.name}.__pow__")
@brettcannon
brettcannon / stats_tables.sql
Last active Jun 26, 2020
Database schema for repo statistics
View stats_tables.sql
CREATE TABLE issues (
recording_date TEXT NOT NULL DEFAULT CURRENT_DATE,
gh_num INTEGER NOT NULL CHECK(gh_num >= 1),
url TEXT NOT NULL,
title TEXT NOT NULL,
created TEXT NOT NULL, -- Date of issue creation
by_team INT NOT NULL DEFAULT 0 CHECK(upvotes >= 0),
assignee TEXT NULL, -- Who the issue is assigned to
last_OP_comment TEXT NULL, -- When the last comment from the OP was
@brettcannon
brettcannon / steps.yml
Created Jan 24, 2020
GitHub Actions steps to cache VS Code stable when running extension tests
View steps.yml
- name: Get VS Code versions
run: curl --output vscode-stable-versions.json https://update.code.visualstudio.com/api/releases/stable
- uses: actions/cache@v1
with:
path: .vscode-test/
key: ${{ runner.os }}-vscode-test-${{ hashFiles('vscode-stable-versions.json') }}
restore-keys: |
${{ runner.os }}-vscode-test-
@brettcannon
brettcannon / parse_wheel_filename.py
Created May 8, 2019
Parse a wheel filename using packaging.tags
View parse_wheel_filename.py
import packaging.tags
def parse_wheel_filename(path):
name = os.path.splitext(_compat.fspath(path))[0]
index = len(name)
for _ in range(3): # interpreter, ABI, platform.
index = name.rindex("-", 0, index)
return packaging.tags.parse_tag(name[index + 1 :])
@brettcannon
brettcannon / cloudSettings
Last active Jun 18, 2018
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2018-06-18T21:57:18.905Z","extensionVersion":"v2.9.2"}
@brettcannon
brettcannon / parse-pylint-list-msgs.py
Last active Mar 9, 2018
Parse the Pylint message list
View parse-pylint-list-msgs.py
import pathlib
import re
SUMMARY_LINE_RE = re.compile(r':(?P<name>\S+) \((?P<code>.+?)\):( \*(?P<summary>.+)\*)?')
def parse_summary_line(line):
line_match = SUMMARY_LINE_RE.match(line)
if not line_match:
raise ValueError(f"ill-formed line: {line!r}")
@brettcannon
brettcannon / 3.5-comparison.txt
Created Sep 13, 2016
Performance comparison between Python 3.5.2+ & 3.6b1+
View 3.5-comparison.txt
+------------------------------------+---------------+---------------+--------------+-------------------------+
| Benchmark | 3.5-perf.json | 3.6-perf.json | Change | Significance |
+====================================+===============+===============+==============+=========================+
| 2to3 | 0.68 | 0.62 | 1.09x faster | Significant (t=65.03) |
+------------------------------------+---------------+---------------+--------------+-------------------------+
| call_method | 0.02 | 0.02 | 1.07x faster | Significant (t=46.01) |
+------------------------------------+---------------+---------------+--------------+-------------------------+
| call_method_slots | 0.02 | 0.02 | 1.06x faster | Significant (t=29.45) |
+------------------------------------+---------------+---------------+--------------+-------------------------+
| call_method_un
@brettcannon
brettcannon / hglookup.py
Last active Nov 28, 2017
hg.python.org/lookup
View hglookup.py
# hglookup.py
#
# Lookup a revision hash in a bunch of different hgwebdir repos.
# Also includes special treatment for subversion revisions from
# the CPython repo.
#
# Written by Georg Brandl, 2010.
import io
import json
@brettcannon
brettcannon / gist:a9c9a5989dc383ed73b4
Last active Sep 19, 2017
Initial email about Python development process and proposed improvements
View gist:a9c9a5989dc383ed73b4

This was posted as an email to python-dev.

History lesson

Since I signed up for the python-dev mailing list way back in June 2002, there seems to be a cycle where we as a group come to a realization that our current software development process has not kept up with modern practices and could stand for an update. For me this was first shown when we moved from SourceForge to our own infrastructure, then again when we moved from Subversion to Mercurial (I led both of these initiatives, so it's somewhat a tradition/curse I find myself in this position yet again). And so we again find ourselves at the point of realizing that we are not keeping up with current practices and thus need to evaluate how we can improve our situation.

Where we are now

Now it should be realized that we have to sets of users of our development process: contributors and core developers (the latter whom can play both roles). If you take a rough outline of our cur