From eb6cefd76509b6cd3103ff2e90deca5072e23050 Mon Sep 17 00:00:00 2001 From: youknowdot Date: Sat, 10 Oct 2026 14:17:08 -0700 Subject: [PATCH] Mark LRU cache wrappers as method descriptors (#9072) Match the Python 3.14 wrapper type flag and enable the existing guarded method-call fast path. Keep the partial vectorcall changes separate. Assisted-by: OpenAI Codex:model identifier unavailable --- crates/vm/src/stdlib/_functools.rs | 2 +- extra_tests/snippets/stdlib_functools.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/vm/src/stdlib/_functools.rs b/crates/vm/src/stdlib/_functools.rs index 4c9725289..49292707a 100644 --- a/crates/vm/src/stdlib/_functools.rs +++ b/crates/vm/src/stdlib/_functools.rs @@ -842,7 +842,7 @@ mod _functools { #[pyclass( with(Constructor, Callable, GetDescriptor), - flags(HAS_DICT, HAS_WEAKREF) + flags(HAS_DICT, HAS_WEAKREF, METHOD_DESCRIPTOR) )] impl Py { #[pymethod] diff --git a/extra_tests/snippets/stdlib_functools.py b/extra_tests/snippets/stdlib_functools.py index 355c31876..2d5c8389d 100644 --- a/extra_tests/snippets/stdlib_functools.py +++ b/extra_tests/snippets/stdlib_functools.py @@ -1,9 +1,13 @@ import gc import weakref +from _functools import _lru_cache_wrapper from functools import cache, cmp_to_key, lru_cache, partial, reduce from testutils import assert_raises +# Cached wrappers support method-descriptor lookup and binding. +assert _lru_cache_wrapper.__flags__ & (1 << 17) + class Squares: def __init__(self, max):