Skip to content

Instantly share code, notes, and snippets.

View youtux's full-sized avatar

Alessio Bogon youtux

View GitHub Profile
@youtux
youtux / pydevd_pep_669_tracing.py.patch
Created December 18, 2025 15:19
Fixing slow pydevd_pep_669_tracing - py_raise_callback
Subject: [PATCH] Add O(1) _is_top_level_frame() check to avoid stack walking
---
Index: _pydevd_bundle/pydevd_pep_669_tracing.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/_pydevd_bundle/pydevd_pep_669_tracing.py b/_pydevd_bundle/pydevd_pep_669_tracing.py
--- a/_pydevd_bundle/pydevd_pep_669_tracing.py (revision 20ca0a6613a48dd84e62ed92bd182b042788e7cb)
+++ b/_pydevd_bundle/pydevd_pep_669_tracing.py (revision 078dd18b21e4c6d7e88a3cfb921a0f37f0c515d9)
@youtux
youtux / 00-README.md
Last active February 19, 2026 12:46
Pycharm debugger performance fixes

PyDevd PEP 669 Performance Fixes - Bug Report

Executive Summary

This document describes critical performance bugs in PyCharm's pydevd_pep_669_tracing.py that cause 11-156x slowdown when debugging Python code, even when no breakpoints are set in the executing code. The fixes improve performance from 4.34 seconds to 0.28 seconds for a test script that calls a simple function 10 million times.

Impact

  • Before: 4.34 seconds (no breakpoints) / 43.06 seconds (with module-level breakpoint)
  • After: 0.277 seconds (no breakpoints) / 0.276 seconds (with module-level breakpoint)
  • Speedup: 15x faster (no breakpoints), 156x faster (module-level breakpoint)
@youtux
youtux / karabiner-nvidia-geforce-now-left-cmd-to-left-click.json
Created July 9, 2022 11:42
Karabiner complex modification to remap Left Command to Left Click in NVIDIA GeForce NOW
{
"title": "Left Command to Left Click in NVIDIA GeForce NOW",
"rules": [
{
"description": "Use Left Command key as Left Click for NVIDIA GeForce NOW gaming",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "left_command",
@youtux
youtux / wrapper.py
Created June 10, 2021 13:55
Python quick n dirty object wrapper
class Wrapper(object):
def __init__(self, wrappee):
self.wrappee = wrappee
# Override your method here
def foo(self):
print('override foo')
def __getattr__(self, attr):
return getattr(self.wrappee, attr)
@youtux
youtux / query_yield_per.py
Created April 26, 2021 08:04
query_yield_per - Execute a sqlalchemy query in many chunks, by advancing the primary key (or any unique key) at each chunk
def query_yield_per(query, next_batch_filter, size, limit=None):
"""Execute a query in many chunks, by advancing the ordering clause.
This is a generator function that yields one element of the query at the time.
The query must already have the ORDER BY clause, and it must not have any LIMIT or OFFSET.
The ``next_batch_filter`` parameter is used to determine the filter condition for each subsequent batch.
It should be a callable with one argument, a the row of the last item in the chunk, and it should return the
filter condition to fetch the next batch.
@youtux
youtux / iter_chunks.py
Created April 26, 2021 08:00
iter_chunks - Split a python iterable in chunks, loading one at a time.
import itertools
def iter_chunks(iterable, chunk_size):
"""Split the iterable in chunks of the given size, loading one chunk at a time.
This function yields lists of size between 1 and `chunk_size`.
:param iterable: the iterable to iterate over
:type iterable: typing.Iterable[T]
:param chunk_size: the size to use for each chunk.
@youtux
youtux / Code usages regular expressions.md
Last active September 21, 2020 13:37
Regular expressions to find code usage

Regular expressions I find useful when looking for code usages

Find python function definitions that use certain arguments

(?s)def\s+[^(]*?\([^)]*?\b(argument1|argument2)\b[^)]*?\)\s*:

@youtux
youtux / my.cnf
Created June 22, 2020 06:55
MySQL configuration with query log and fix for mac os file limit
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
general_log_file = /usr/local/var/mysql/Argon.local.log
general_log = ON
# Since MySQL 5.6 innodb_file_per_table option is ON by default,
# which means that each table's data is stored in its own file.
# OSX default limit of the number of the open files is 256 per process.
"""Quick and dirty ScalarListField for django"""
from django import forms
import six
class ScalarListField(forms.CharField):
widget = forms.Textarea
def __init__(self, separator="\n", **kwargs):
self.separator = separator
@youtux
youtux / test_sqla_relations_backpopulate_primaryjoin.py
Created May 23, 2019 13:36
PoC to have sqlalchemy relationship backpopulate correctly even with custom primaryjoin condition
def test_relationships_backpopulate_primaryjoin():
Base = declarative_base()
class Post(Base):
__tablename__ = 'post'
id = Column(Integer, primary_key=True, autoincrement=True)
text = Column(String(255))
active = Column(Boolean())