Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-115776: Embed the values array into the object, for "normal" Python objects.#116115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 35 commits intopython:mainfromfaster-cpython:inline-values
Apr 2, 2024

Conversation

markshannon
Copy link
Member

@markshannonmarkshannon commentedFeb 29, 2024
edited by bedevere-appbot
Loading

A "normal" Python object is one that:

  • Doesn't inherit from a builtin class
  • Does not have__slots__

@markshannonmarkshannon marked this pull request as ready for reviewMarch 26, 2024 17:14
Copy link
Contributor

@DinoVDinoV left a comment

Choose a reason for hiding this comment

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

Looks awesome, just a few nits!

@markshannonmarkshannon merged commitc32dc47 intopython:mainApr 2, 2024
if (_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE)) {
Py_INCREF(typeobj);
}
assert(_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE) || _Py_IsImmortal(typeobj));
Copy link
Contributor

Choose a reason for hiding this comment

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

I now hit this assertion in Cython modules. The (static) extension type that we use for generators hastp_alloc = PyType_GenericAlloc and calls it intp_new():

#6  0x00007ffff7cc2e96 in __GI___assert_fail (assertion=assertion@entry=0x5555559db4e0 "_PyType_HasFeature(typeobj, Py_TPFLAGS_HEAPTYPE) || _Py_IsImmortal(typeobj)", file=file@entry=0x5555559db468 "./Include/internal/pycore_object.h", line=line@entry=268, function=function@entry=0x555555a04ad8 <__PRETTY_FUNCTION__.140> "_PyObject_Init") at ./assert/assert.c:101#7  0x0000555555774e33 in _PyObject_Init (typeobj=0x7ffff6c26d40 <__pyx_type_8buildenv___pyx_scope_struct__genexpr>, op=0x7ffff4f1e210) at ./Include/internal/pycore_object.h:268#8  0x000055555577cec3 in _PyObject_Init (typeobj=<optimized out>, op=<optimized out>) at ./Include/object.h:430#9  _PyType_AllocNoTrack (type=type@entry=0x7ffff6c26d40 <__pyx_type_8buildenv___pyx_scope_struct__genexpr>, nitems=0) at Objects/typeobject.c:1908#10 0x000055555577cf09 in PyType_GenericAlloc (type=0x7ffff6c26d40 <__pyx_type_8buildenv___pyx_scope_struct__genexpr>, nitems=<optimized out>) at Objects/typeobject.c:1922#11 0x00007ffff6c08100 in __pyx_tp_new_8buildenv___pyx_scope_struct__genexpr (t=<optimized out>, a=<optimized out>, k=k@entry=0x0) at buildenv.c:2954

Is this assertion simply wrong, or is there anything I can do to avoid it? The "immortal objects" API doesn't seem to be intended for public use.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

#19474 sets the reference count to 1 for statically allocated objects unlessPy_BUILD_CORE is defined.

As a workaround, I'd suggest making these classes immortal and making them immutable if you can.

The "immortal objects" API doesn't seem to be intended for public use.

That does seem to be the case. I don't know why. Want to open an issue for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why this new assertion exists? The previousif condition came from a conservative change that intended to avoid refcounting static types but wanted to make sure (heap) type objects are correctly kept alive as long as their objects. Now the code requires all non-heap types to be declared immortal. That seems a rather heavy change in requirements.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

All non-heap types are immortal. Requiring that they are declared as such seems reasonable, and is probably necessary for memory safety.

I don't think you should need to do so explicitly though,PyObject_HEAD_INIT should do it.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Does#117673 fix the problem for you?

diegorusso pushed a commit to diegorusso/cpython that referenced this pull requestApr 17, 2024
@markshannonmarkshannon deleted the inline-values branchAugust 6, 2024 10:16
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 22, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 25, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
williamwen42 added a commit to pytorch/pytorch that referenced this pull requestOct 25, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames rec[ghstack-poisoned]
pytorchmergebot pushed a commit to pytorch/pytorch that referenced this pull requestOct 28, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.Pull Requestresolved:#138284Approved by:https://github.com/janselghstack dependencies:#138030
rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this pull requestOct 29, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.Pull Requestresolved:pytorch#138284Approved by:https://github.com/janselghstack dependencies:pytorch#138030
rahulsingh-intel pushed a commit to rahulsingh-intel/pytorch that referenced this pull requestNov 5, 2024
python/cpython#116115 introduced a bug (python/cpython#125608) where changing the attributes of an object may not fire the dict watchers registered to the object's `__dict__`. It has been fixed bypython/cpython#125611 but will only be in 3.13.1+.This PR disables the dict watcher guard shortcut for `__dict__`s on 3.13.0 and warns the user to try using 3.13.1+ instead. We also added a simple test to check for this functionality in the future.Pull Requestresolved:pytorch#138284Approved by:https://github.com/janselghstack dependencies:pytorch#138030
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@scoderscoderscoder left review comments

@colesburycolesburycolesbury left review comments

@corona10corona10corona10 left review comments

@erlend-aaslanderlend-aaslanderlend-aasland left review comments

@DinoVDinoVDinoV approved these changes

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@methanemethaneAwaiting requested review from methanemethane is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@markshannon@DinoV@scoder@colesbury@corona10@erlend-aasland

[8]ページ先頭

©2009-2025 Movatter.jp