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-93911:LOAD_ATTR_PROPERTY#93912

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
Fidget-Spinner merged 14 commits intopython:mainfromFidget-Spinner:load_attr_property
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
14 commits
Select commitHold shift + click to select a range
c9966d1
More LOAD_ATTR specializations
Fidget-SpinnerJun 16, 2022
e66782b
📜🤖 Added by blurb_it.
blurb-it[bot]Jun 16, 2022
c7bde64
fix compiler warnings
Fidget-SpinnerJun 16, 2022
6a03dad
Fix double backticks
Fidget-SpinnerJun 16, 2022
c78831d
Apply Mark's suggestions
Fidget-SpinnerJun 16, 2022
d03cc61
try to fix compiler warnings
Fidget-SpinnerJun 16, 2022
36af644
re-enable LOAD_ATTR_CLASS_MUTABLE_DESCRIPTOR
Fidget-SpinnerJun 16, 2022
c20af47
Remove double stat count
Fidget-SpinnerJun 16, 2022
3d5d5fd
remove LOAD_ATTR_MUTABLE_CLASS_DESCRIPTOR
Fidget-SpinnerJun 16, 2022
7f45ec1
Delete 2022-06-16-08-56-26.gh-issue-93657.AZG2WT.rst
Fidget-SpinnerJun 16, 2022
a6c4ab3
📜🤖 Added by blurb_it.
blurb-it[bot]Jun 16, 2022
626bfa1
fix up stats and deopt
Fidget-SpinnerJun 17, 2022
4786bac
Use 32 bit func_version
Fidget-SpinnerJun 17, 2022
9f32d03
remove the version check
Fidget-SpinnerJun 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletionsInclude/internal/pycore_descrobject.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
#ifndefPy_INTERNAL_DESCROBJECT_H
Copy link
Member

Choose a reason for hiding this comment

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

Maybe "pycore_property.h" as it is just the property struct.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm leaving it generic from now (and naming it after the file it came from) so that I can re-use it again in the future when I add more specialisations. (E.g. classmethod is also from the same file)

Copy link
Member

Choose a reason for hiding this comment

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

Do properties and classmethods really belong in the same file? Sure, they are both descriptors, but so are Python functions.
The file layout is a bit of an historical artifact.

Copy link
Member

Choose a reason for hiding this comment

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

If you don't want to change it for this PR, that's fine too.

Fidget-Spinner reacted with thumbs up emoji
#definePy_INTERNAL_DESCROBJECT_H
#ifdef__cplusplus
extern"C" {
#endif

#ifndefPy_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

typedefstruct {
PyObject_HEAD
PyObject*prop_get;
PyObject*prop_set;
PyObject*prop_del;
PyObject*prop_doc;
PyObject*prop_name;
intgetter_doc;
}propertyobject;

typedefpropertyobject_PyPropertyObject;

#ifdef__cplusplus
}
#endif
#endif/* !Py_INTERNAL_DESCROBJECT_H */
27 changes: 14 additions & 13 deletionsInclude/internal/pycore_opcode.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

53 changes: 27 additions & 26 deletionsInclude/opcode.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionsLib/opcode.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -287,6 +287,7 @@ def jabs_op(name, op):
"LOAD_ATTR_CLASS",
"LOAD_ATTR_INSTANCE_VALUE",
"LOAD_ATTR_MODULE",
"LOAD_ATTR_PROPERTY",
"LOAD_ATTR_SLOT",
"LOAD_ATTR_WITH_HINT",
# These will always push [unbound method, self] onto the stack.
Expand Down
1 change: 1 addition & 0 deletionsMakefile.pre.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1595,6 +1595,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_condvar.h \
$(srcdir)/Include/internal/pycore_context.h \
$(srcdir)/Include/internal/pycore_dict.h \
$(srcdir)/Include/internal/pycore_descrobject.h \
$(srcdir)/Include/internal/pycore_dtoa.h \
$(srcdir)/Include/internal/pycore_exceptions.h \
$(srcdir)/Include/internal/pycore_fileutils.h \
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Specialize ``LOAD_ATTR`` for ``property()`` attributes.
11 changes: 1 addition & 10 deletionsObjects/descrobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "structmember.h" // PyMemberDef
#include "pycore_descrobject.h"

/*[clinic input]
class mappingproxy "mappingproxyobject *" "&PyDictProxy_Type"
Expand DownExpand Up@@ -1501,16 +1502,6 @@ class property(object):

*/

typedef struct {
PyObject_HEAD
PyObject *prop_get;
PyObject *prop_set;
PyObject *prop_del;
PyObject *prop_doc;
PyObject *prop_name;
int getter_doc;
} propertyobject;

static PyObject * property_copy(PyObject *, PyObject *, PyObject *,
PyObject *);

Expand Down
1 change: 1 addition & 0 deletionsPCbuild/pythoncore.vcxproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -207,6 +207,7 @@
<ClInclude Include="..\Include\internal\pycore_compile.h" />
<ClInclude Include="..\Include\internal\pycore_condvar.h" />
<ClInclude Include="..\Include\internal\pycore_context.h" />
<ClInclude Include="..\Include\internal\pycore_descrobject.h" />
<ClInclude Include="..\Include\internal\pycore_dtoa.h" />
<ClInclude Include="..\Include\internal\pycore_exceptions.h" />
<ClInclude Include="..\Include\internal\pycore_fileutils.h" />
Expand Down
3 changes: 3 additions & 0 deletionsPCbuild/pythoncore.vcxproj.filters
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -528,6 +528,9 @@
<ClInclude Include="..\Include\internal\pycore_context.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_descrobject.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_dtoa.h">
<Filter>Include\internal</Filter>
</ClInclude>
Expand Down
46 changes: 42 additions & 4 deletionsPython/ceval.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3627,7 +3627,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}

TARGET(LOAD_ATTR_CLASS) {
/* LOAD_METHOD, for class methods */
assert(cframe.use_tracing == 0);
_PyLoadMethodCache *cache = (_PyLoadMethodCache *)next_instr;

Expand All@@ -3650,6 +3649,46 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
NOTRACE_DISPATCH();
}

TARGET(LOAD_ATTR_PROPERTY) {
assert(cframe.use_tracing == 0);
DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR);
_PyLoadMethodCache *cache = (_PyLoadMethodCache *)next_instr;

PyObject *owner = TOP();
PyTypeObject *cls = Py_TYPE(owner);
uint32_t type_version = read_u32(cache->type_version);
DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR);
assert(type_version != 0);
PyObject *fget = read_obj(cache->descr);
PyFunctionObject *f = (PyFunctionObject *)fget;
uint32_t func_version = read_u32(cache->keys_version);
assert(func_version != 0);
DEOPT_IF(f->func_version != func_version, LOAD_ATTR);
PyCodeObject *code = (PyCodeObject *)f->func_code;
assert(code->co_argcount == 1);
STAT_INC(LOAD_ATTR, hit);

Py_INCREF(fget);
_PyInterpreterFrame *new_frame = _PyFrame_Push(tstate, f);
if (new_frame == NULL) {
goto error;
}
SET_TOP(NULL);
int push_null = !(oparg & 1);
STACK_SHRINK(push_null);
new_frame->localsplus[0] = owner;
for (int i = 1; i < code->co_nlocalsplus; i++) {
new_frame->localsplus[i] = NULL;
}
_PyFrame_SetStackPointer(frame, stack_pointer);
JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR);
frame->prev_instr = next_instr - 1;
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
CALL_STAT_INC(inlined_py_calls);
goto start_frame;
}

TARGET(STORE_ATTR_ADAPTIVE) {
assert(cframe.use_tracing == 0);
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
Expand DownExpand Up@@ -4549,7 +4588,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}

TARGET(LOAD_ATTR_METHOD_WITH_VALUES) {
/*LOAD_METHOD, with cached method object */
/*Cached method object */
assert(cframe.use_tracing == 0);
PyObject *self = TOP();
PyTypeObject *self_cls = Py_TYPE(self);
Expand All@@ -4575,8 +4614,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}

TARGET(LOAD_ATTR_METHOD_WITH_DICT) {
/* LOAD_METHOD, with a dict
Can be either a managed dict, or a tp_dictoffset offset.*/
/* Can be either a managed dict, or a tp_dictoffset offset.*/
assert(cframe.use_tracing == 0);
PyObject *self = TOP();
PyTypeObject *self_cls = Py_TYPE(self);
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp