Skip to content

Instantly share code, notes, and snippets.

#include "Python.h"
PyObject* get_message(PyObject* self, PyObject* args) {
PyObject* message = PyUnicode_FromString("hello from extension");
return message;
}
static PyMethodDef hello_methods[] = {
{"get_message",
get_message,
@itamaro
itamaro / build.sh
Created May 21, 2023 18:42
py-setproctitle find_argv_from_env heap buffer underflow repro
# build it with ASAN
clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer test.cpp -o test
Benchmarks with tag 'apps':
===========================
Benchmark hidden because not significant (4): 2to3, docutils, html5lib, tornado_http
Benchmarks with tag 'math':
===========================
+----------------+---------------------------+----------------------------+
| Benchmark | 3.12-full-base.20230429.2 | 3.12-full-defer.20230429.2 |
@itamaro
itamaro / deferred_asyncio_task_name_formatting
Created April 24, 2023 20:23
pyperformance results for deferring asyncio task name formatting
3.12-baseline.20230424.1.json
=============================
Performance version: 1.0.7
Report on Linux-5.15.0-1033-aws-x86_64-with-glibc2.31
Number of logical CPUs: 72
Start date: 2023-04-24 16:20:46.174823
End date: 2023-04-24 17:56:34.787522
3.12-defer-task-name-format.20230424.1.json
@itamaro
itamaro / pyperf_compare_to.md
Last active March 20, 2023 23:10
pyperformance results for cpython gh-102853 (eager tasks factory)

Benchmarks with tag 'apps':

Benchmark baseline_20230316.2 eagertasks_20230316.2
2to3 579 ms 581 ms: 1.00x slower
Geometric mean (ref) 1.00x faster

Benchmark hidden because not significant (4): chameleon, docutils, html5lib, tornado_http

@itamaro
itamaro / gist:fbcf5733d40fc3957d952f54d6d3e9e9
Created November 28, 2022 23:04
pyperformance benchmarks results for CPython gh-91054 - code object watchers
$ pyperformance compare benchmarks/gh-91054.json benchmarks/gh-91054-baserev.json -O table
gh-91054.json
=============
Performance version: 1.0.6
Report on Linux-5.15.0-1022-aws-x86_64-with-glibc2.31
Number of logical CPUs: 72
Start date: 2022-11-28 21:33:26.652340
End date: 2022-11-28 22:52:43.947737
@itamaro
itamaro / module_locator.py
Last active August 29, 2015 13:56
The best way to determine the location of a Python script (source: Stack Overflow, http://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python)
import sys
import os
def we_are_frozen():
# All of the modules are built-in to the interpreter, e.g., by py2exe
return hasattr(sys, "frozen")
def module_path():
encoding = sys.getfilesystemencoding()
if we_are_frozen():

This is a Test

Hello, //world//

@itamaro
itamaro / cmd.ahk
Created August 24, 2013 14:34
Launching the Command Prompt from Anywhere with AutoHotKey
;Launch Command Prompt From Anywhere
;CTRL+ALT+T (Linux style Terminal)
^!t::
CmdFolder := "C:\Path\To\Default\Dir"
IfWinActive ahk_class CabinetWClass
{
; This is required to get the full path of the file from the address bar
WinGetText, full_path, A
; Split on newline (`n)