Skip to content

Introduce support for Python 3.14 - #656

Merged
ajaust merged 2 commits into
equinor:mainfrom
ajaust:enable-py314
Nov 21, 2025
Merged

Introduce support for Python 3.14#656
ajaust merged 2 commits into
equinor:mainfrom
ajaust:enable-py314

Conversation

@ajaust

@ajaust ajaust commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Fix RefTrace's garbage collection had to be adapted due Python 3.14's changes to object reference counting. I also enabled Python 3.14 as part of the wheels build again.

@achaikou achaikou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this change wasn't anything bad! 👍
Now we just need to drop 3.9 and we are ready to go!


Regarding commit message:

I would have linked to
https://docs.python.org/3/whatsnew/3.14.html#optimizations
instead. I think it is more clear as the linked link leads to some internal C changes.

Also:

The difference comes from RefTrace's fetch method:
in Python 3.14, its return value has a reference count of 0, while in
older versions it has reference count 1.

I don't think it is the root cause of the difference.
I think the difference is sys.getrefcount() itself that no longer increases reference count. It has nothing to do with fetch.

Comment thread python/segyio/trace.py Outdated

@ajaust ajaust left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I updated the comment and the commit message and added one fixup to move the new variable into the fetch method.

Comment thread python/segyio/trace.py Outdated

@achaikou achaikou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me likes that!

Python 3.14 changed how object reference counts work [1], often
resulting in lower counts than before. In RefTrace, this reduces the
internal trace reference count from 3 to 2 for objects that may be
garbage collected.

[1]: https://docs.python.org/3/whatsnew/3.14.html#optimizations
@ajaust
ajaust merged commit 1286090 into equinor:main Nov 21, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants