cpython/Lib/test/test_free_threading
Neil Schemenauer cdba68e563
[3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725)
Setting __name__, __qualname__, __doc__ or __module__ on a function
stopped the world in the free-threaded build since gh-154826 and
gh-154851, making functools.wraps() orders of magnitude slower with
multiple threads.

Use the per-object critical section and _PyObject_XSetRefDelayed()
instead, as gen_set_name() already does.  Use acquire loads in the
readers and hold strong references across error reporting, tracing, and
eval-frame recording that may execute Python or detach the thread.  The
__code__, __defaults__, __kwdefaults__ and __closure__ setters still
stop the world to clear func_version.

Document synchronization requirements for direct field access and the
lifetime of borrowed function attributes.

(cherry picked from commit 010bebbf9f)
2026-10-29 15:17:50 -07:00
..
__init__.py
test_bisect.py
test_bytes_object.py
test_bz2.py
test_capi.py
test_code.py
test_collections.py
test_context.py
test_cprofile.py
test_csv.py
test_datetime.py
test_dbm_gnu.py
test_dict.py
test_dict_watcher.py
test_enumerate.py
test_exceptions.py
test_frame.py
test_func_annotations.py
test_functions.py [3.15] gh-159136: Avoid stop-the-world when setting function name attributes (gh-159269) (gh-159725) 2026-10-29 15:17:50 -07:00
test_functools.py
test_gc.py
test_generators.py
test_grp.py
test_heapq.py
test_io.py
test_iteration.py
test_itertools.py
test_itertools_combinatoric.py
test_json.py
test_list.py
test_lzma.py
test_methodcaller.py
test_mmap.py
test_monitoring.py
test_os.py
test_pickle.py
test_pwd.py
test_races.py
test_re.py
test_readline.py
test_resource.py
test_reversed.py
test_set.py
test_slots.py
test_sqlite3.py
test_str.py
test_string_template_race.py
test_suggestions.py
test_sys.py
test_syslog.py
test_threading.py
test_tokenize.py
test_type.py
test_types.py
test_uuid.py
test_weakref.py
test_zip.py
test_zlib.py