Skip to content

Instantly share code, notes, and snippets.

View pablogsal's full-sized avatar
🤘

Pablo Galindo Salgado pablogsal

🤘
View GitHub Profile
@pablogsal
pablogsal / malloc_comparison.svg
Created January 28, 2026 15:25
pymalloc vs system malloc benchmark comparison
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
file,import_line,import_api,variable,attr_access_api,attr_access_line,import_code,attr_access_code
Modules/_asynciomodule.c,4264,PyImport_ImportModule,asyncio_mod,NONE DETECTED,,"state->asyncio_mod = PyImport_ImportModule(""asyncio"");",
Modules/_asynciomodule.c,4281,PyImport_ImportModule,module,PyObject_GetAttrString,4287,module = PyImport_ImportModule(NAME); \,"VAR = PyObject_GetAttrString(module, NAME); \"
Modules/_ctypes/callbacks.c,474,PyImport_ImportModuleAttrString,func,NONE DETECTED,,"func = PyImport_ImportModuleAttrString(""ctypes"", ""DllGetClassObject"");",
Modules/_ctypes/callbacks.c,543,PyImport_ImportModuleAttrString,func,NONE DETECTED,,"PyObject *func = PyImport_ImportModuleAttrString(""ctypes"",",
Modules/_ctypes/stgdict.c,272,PyImport_ImportModuleAttrString,layout_func,NONE DETECTED,,"layout_func = PyImport_ImportModuleAttrString(""ctypes._layout"", ""get_layout"");",
Modules/_cursesmodule.c,328,PyImport_ImportModuleAttrString,exc,NONE DETECTED,,"PyObject *exc = PyImport_ImportModuleAttrStrin
how do you feel about these stacks?
Traceback for thread 2896 (python) [Garbage collecting] (most recent call last):
(C) File "???", line 0, in _start (/home/mwoznisk/3ps/cpython/python)
(C) File "../csu/libc-start.c", line 302, in __libc_start_main (/usr/lib64/libc-2.28.so)
(C) File "Modules/main.c", line 829, in Py_BytesMain (/home/mwoznisk/3ps/cpython/python)
(C) File "Modules/main.c", line 805, in pymain_main (inlined) (/home/mwoznisk/3ps/cpython/python)
(C) File "Modules/main.c", line 777, in Py_RunMain (inlined) (/home/mwoznisk/3ps/cpython/python)
(C) File "Python/gc_free_threading.c", line 2608, in PyGC_Collect (/home/mwoznisk/3ps/cpython/python)
(C) File "Python/gc_free_threading.c", line 2314, in gc_collect_main.constprop.0 (/home/mwoznisk/3ps/cpython/python)
(C) File "Python/gc_free_threading.c", line 2144, in gc_collect_internal (inlined) (/home/mwoznisk/3ps/cpython/python)
#1 _PyCode_GetTLBCArray (co=0x0) at ./Include/internal/pycore_code.h:529
529 return _Py_STATIC_CAST(_PyCodeArray *,
(gdb) up
#2 _PyFrame_GetBytecode (f=0x727f2e2331a8) at ./Include/internal/pycore_interpframe.h:32
32 _PyCodeArray *tlbc = _PyCode_GetTLBCArray(co);
(gdb) up
#3 PyUnstable_InterpreterFrame_GetLine (frame=0x727f2e2331a8) at Python/frame.c:149
149 int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
(gdb) p *frame
$1 = {f_executable = 0x0, previous = 0x727f2e233128, f_funcobj = 0x0,
#1 _PyCode_GetTLBCArray (co=0x0) at ./Include/internal/pycore_code.h:529
529 return _Py_STATIC_CAST(_PyCodeArray *,
(gdb) up
#2 _PyFrame_GetBytecode (f=0x727f2e2331a8) at ./Include/internal/pycore_interpframe.h:32
32 _PyCodeArray *tlbc = _PyCode_GetTLBCArray(co);
(gdb) up
#3 PyUnstable_InterpreterFrame_GetLine (frame=0x727f2e2331a8) at Python/frame.c:149
149 int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
(gdb) p *frame
$1 = {f_executable = 0x0, previous = 0x727f2e233128, f_funcobj = 0x0,
import sys
import threading
import time
from memray._test import MemoryAllocator
def background_attacher():
time.sleep(1)
import memray
import argparse
import _remote_debugging
import time
import signal
from collections import defaultdict
class SamplingProfiler:
def __init__(self):
self.function_stats = defaultdict(lambda: {'ncalls': 0, 'tottime': 0.0})
self.total_samples = 0
import tokenize
from io import BytesIO
from typing import List, Tuple, Optional, Dict, Any
import keyword
from codeop import compile_command
from _suggestions import _generate_suggestions
from textwrap import dedent
class StatementFinder:
"""Finds the smallest surrounding statement given a line number and Python source."""
#include <elf.h>
#include <execinfo.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#define UNW_LOCAL_ONLY
#include <libunwind.h>
// AArch64 registers