GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python 3.14 free-threaded support · Issue #2720 · pythonnet/pythonnet

Python 3.14 free-threaded support #2720

New issue
Copy link
New issue
Copy link
Closed
Closed
Python 3.14 free-threaded support#2720
Copy link
Milestone
3.2.0

Description

@greateggsgreg
greateggsgreg
opened on May 9, 2026
Issue body actions

Tracking issue for free-threaded Python (Py_GIL_DISABLED) support. Companion to the umbrella 3.14 tracker #2610.

Why FT is different from a normal GIL build

  • PyObject_HEAD is 16 bytes larger; the refcount is split across ob_ref_local + ob_ref_shared and must be read via Py_REFCNT (a real exported symbol on 3.14+).
  • Build detection: sys._is_gil_enabled() (added in 3.13) returns False on FT.
  • The GIL has been silently serialising every pythonnet static cache, lock-free counter, finalizer-thread interaction, and Reflection.Emit use site. All of those need explicit synchronisation under FT.

Hazards in pythonnet (resolved by PR #2721)

Area What broke How it was fixed
Refcount / ABI Single-offset read Py_REFCNT P/Invoke + ObjectHeadOffset = 16 for FT
Type-creation race Duplicate cache.Add; partial-type visibility Two-cache (cache + _inProgressCache) under _cacheCreateLock
GCHandle in tp_clear/tp_dealloc Double-free under main-thread + finalizer-thread race Interlocked.Exchange on the slot
Reflection.Emit Concurrent DefineType corrupts IL / throws "Duplicate type name" Lock both CreateDerivedType and DelegateManager.GetDispatcher
Static collections Plain Dictionary/HashSet/List thread-safety issues ConcurrentDictionary where possible; Interlocked/Volatile for single-cell state; locks for nested mutation and ordered list semantics
Finalizer-thread / Py_Finalize interaction Stale ob_ref_local reads after teardown crash the process Runtime._Py_IsFinalizing() guards on all decref-from-finalizer paths
Chained ClassDerived.Finalize IL Nested Python-derived classes with __namespace__ chained through emitted Finalize methods, queuing the same __pyobj__ twice → PyObject_GC_Del on freed memory Skip the base-Finalize chain when the base is itself pythonnet-emitted (IPythonDerivedType)

See PR #2721 for the per-file detail.

References

  • PR: Python 3.14 free-threaded support #2721
  • Umbrella 3.14 tracker: Add support for Python 3.14 #2610
  • CPython PEP 703: https://peps.python.org/pep-0703/
  • CPython 3.14 free-threading docs: https://docs.python.org/3.14/howto/free-threading-extensions.html

Activity

  1. filmor
    added 2 commits that reference this issue on May 12, 2026

    Initialise pythonnet on free-threaded Python (pythonnet#2720)

    ca4b4dc

    Initialise pythonnet on free-threaded Python (pythonnet#2720)

    cf8372a
  2. filmor
    added this to the 3.2.0 milestone on May 26, 2026
  3. Huaian666 commented on Jun 5, 2026

    @Huaian666
    Huaian666
    on Jun 5, 2026
    More actions

    idk who designed the api but they clearly actually use their own product. everything is where you'd expect it to be. refreshing.

  4. filmor
    added a commit that references this issue on Aug 18, 2026

    Initialise pythonnet on free-threaded Python (pythonnet#2720)

    e029137
  5. filmor
    added a commit that references this issue on Sep 14, 2026

    Python 3.14 free-threaded support (#2721)

    7b08d70
  6. filmor
    closed this as completedon Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      • 3.2.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.