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

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion 2 Include/internal/pycore_opcode_metadata.h

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

2 changes: 1 addition & 1 deletion 2 Include/internal/pycore_uop_ids.h

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

6 changes: 3 additions & 3 deletions 6 Include/internal/pycore_uop_metadata.h

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

1 change: 1 addition & 0 deletions 1 Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,7 @@ def testfunc(n):
self.assertIn("_CALL_LEN", uops)
self.assertNotIn("_GUARD_NOS_INT", uops)
self.assertNotIn("_GUARD_TOS_INT", uops)
self.assertIn("_POP_TOP_NOP", uops)

def test_call_len_known_length_small_int(self):
# Make sure that len(t) is optimized for a tuple of length 5.
Expand Down
13 changes: 7 additions & 6 deletions 13 Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4282,17 +4282,18 @@ dummy_func(
unused/2 +
_GUARD_NOS_NULL +
_GUARD_CALLABLE_LEN +
_CALL_LEN;
_CALL_LEN +
POP_TOP +
POP_TOP;

op(_GUARD_CALLABLE_LEN, (callable, unused, unused -- callable, unused, unused)){
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyInterpreterState *interp = tstate->interp;
DEOPT_IF(callable_o != interp->callable_cache.len);
}

op(_CALL_LEN, (callable, null, arg -- res)) {
op(_CALL_LEN, (callable, null, arg -- res, a, c)) {
/* len(o) */
(void)null;
STAT_INC(CALL, hit);
PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg);
Py_ssize_t len_i = PyObject_Length(arg_o);
Expand All @@ -4304,9 +4305,9 @@ dummy_func(
if (res_o == NULL) {
ERROR_NO_POP();
}
PyStackRef_CLOSE(arg);
DEAD(null);
PyStackRef_CLOSE(callable);
a = arg;
c = callable;
Comment thread
Fidget-Spinner marked this conversation as resolved.
INPUTS_DEAD();
res = PyStackRef_FromPyObjectSteal(res_o);
}

Expand Down
29 changes: 11 additions & 18 deletions 29 Python/executor_cases.c.h

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

27 changes: 19 additions & 8 deletions 27 Python/generated_cases.c.h

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

4 changes: 3 additions & 1 deletion 4 Python/optimizer_bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ dummy_func(void) {
sym_set_const(callable, (PyObject *)&PyUnicode_Type);
}

op(_CALL_LEN, (callable, null, arg -- res)) {
op(_CALL_LEN, (callable, null, arg -- res, a, c)) {
res = sym_new_type(ctx, &PyLong_Type);
Py_ssize_t tuple_length = sym_tuple_length(arg);
if (tuple_length >= 0) {
Expand All @@ -1216,6 +1216,8 @@ dummy_func(void) {
res = sym_new_const(ctx, temp);
Py_DECREF(temp);
}
a = arg;
c = callable;
}

op(_GET_LEN, (obj -- obj, len)) {
Expand Down
11 changes: 8 additions & 3 deletions 11 Python/optimizer_cases.c.h

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

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.