-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Changes from all commits
bf0394d
23877ec
381f3d3
c2b141e
8b73d0d
7cb3dad
79b6d11
039b14d
c33abbf
d105cac
e7c4bf2
c080089
1b177e3
243e441
a79e36b
7392593
17b453a
baa1009
44d3f47
06330b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ extern "C" { | |
and coroutine objects. */ | ||
#define _PyGenObject_HEAD(prefix) \ | ||
PyObject_HEAD \ | ||
/* Note: gi_frame can be NULL if the generator is "finished" */ \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a question about gi_iframe. Below (L31) it is defined as an array of length 1 of object pointers. But everywhere it's used, it is cast to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a lie. We don't want to expose InterpreterFrame gi_frame; as C won't allow incomplete types in structs, even as the last member. We could improve this by breaking up the header, so the public API sees a different definition. Still a lie, but a more elegant one. typedef struct {
_PyGenObject_HEAD(gi)
} PyGenObject; Private header: typedef struct {
_PyGenObject_HEAD(gi)
InterpreterFrame gi_frame;
} PyGenObject; Probably best done in a different PR, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. Any type other than PyObject* would be better though :-). And if you replace the casts with a macro it’s easier to fix later. I have an idea for the macro but it’s too painful to type on a phone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first field of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/* The code object backing the generator */ \ | ||
PyCodeObject *prefix##_code; \ | ||
/* List of weak reference. */ \ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Add new ``RETURN_GENERATOR`` bytecode to make generators. | ||
Simplifies calling Python functions in the VM, as they no | ||
longer any need to special case generator functions. | ||
|
||
Also add ``JUMP_NO_INTERRUPT`` bytecode that acts like | ||
``JUMP_ABSOLUTE``, but does not check for interrupts. |
Uh oh!
There was an error while loading. Please reload this page.