10000 bpo-46409: Make generators in bytecode by markshannon · Pull Request #30633 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-46409: Make generators in bytecode #30633

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Remove unused code.
  • Loading branch information
markshannon committed Jan 17, 2022
commit c2b141e54b21d00a1d92238a0710a261f5035a1b
1 change: 0 additions & 1 deletion Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ async def runner():
self.loop.run_until_complete(runner())

def test_task_repr(self):
self.maxDiff = None
self.loop.set_debug(False)

async def notmuch():
Expand Down
3 changes: 0 additions & 3 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1335,9 +1335,6 @@ compute_cr_origin(int origin_depth, InterpreterFrame *current_frame)
return NULL;
}
frame = current_frame;
if (frame) {

}
for (int i = 0; i < frame_count; ++i) {
PyCodeObject *code = frame->f_code;
PyObject *frameinfo = Py_BuildValue("OiO",
Expand Down
43 changes: 1 addition & 42 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,49 +1757,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
#endif

DISPATCH();
check_eval_breaker:
{
assert(STACK_LEVEL() >= 0); /* else underflow */
assert(STACK_LEVEL() <= frame->f_code->co_stacksize); /* else overflow */
assert(!_PyErr_Occurred(tstate));

/* Do periodic things. Doing this every time through
the loop would add too much overhead, so we do it
only every Nth instruction. We also do it if
``pending.calls_to_do'' is set, i.e. when an asynchronous
event needs attention (e.g. a signal handler or
async I/O handler); see Py_AddPendingCall() and
Py_MakePendingCalls() above. */

if (_Py_atomic_load_relaxed(eval_breaker)) {
opcode = _Py_OPCODE(*next_instr);
if (opcode != BEFORE_ASYNC_WITH &&
opcode != SEND &&
_Py_OPCODE(next_instr[-1]) != SEND) {
/* Few cases where we skip running signal handlers and other
pending calls:
- If we're about to enter the 'with:'. It will prevent
emitting a resource warning in the common idiom
'with open(path) as file:'.
- If we're about to enter the 'async with:'.
- If we're about to enter the 'try:' of a try/finally (not
*very* useful, but might help in some cases and it's
traditional)
- If we're resuming a chain of nested 'yield from' or
'await' calls, then each frame is parked with YIELD_FROM
as its next opcode. If the user hit control-C we want to
wait until we've reached the innermost frame before
running the signal handler and raising KeyboardInterrupt
(see bpo-30039).
*/
if (eval_frame_handle_pending(tstate) != 0) {
goto error;
}
}
}

DISPATCH();

{
/* Start instructions */
#if USE_COMPUTED_GOTOS
{
Expand Down
14 changes: 0 additions & 14 deletions Python/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,9 @@ _PyFrame_Traverse(InterpreterFrame *frame, visitproc visit, void *arg)
return 0;
}

static int
frame_is_initialized(InterpreterFrame *frame)
{
if (frame->f_lasti < 0) {
return 0;
}
int opcode = _Py_OPCODE(frame->f_code->co_firstinstr[frame->f_lasti]);
if (opcode == MAKE_CELL || opcode == COPY_FREE_VARS) {
return 0;
}
return 1;
}

PyFrameObject *
_PyFrame_MakeAndSetFrameObject(InterpreterFrame *frame)
{
assert(frame_is_initialized(frame));
assert(frame->frame_obj == NULL);
PyObject *error_type, *error_value, *error_traceback;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
Expand Down
0