-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-12414: Update code_sizeof() to take in account co_extras #1168
Conversation
@corona10, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @serhiy-storchaka and @benjaminp to be potential reviewers. |
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
75d8644
to
c2aad6e
Compare
Objects/codeobject.c
Outdated
if (co->co_cell2arg != NULL && co->co_cellvars != NULL) | ||
res += PyTuple_GET_SIZE(co->co_cellvars) * sizeof(Py_ssize_t); | ||
|
||
if (co_extra != NULL) | ||
res += co_extra->ce_size * sizeof(co_extra->ce_extras[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this indentation correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serhiy-storchaka
Oh! I will fix this indent!
Is there any tool for auto-formatting to solve this kind of indentation problem?
e.g make format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tools for auto-formatting are used with CPython sources. You should follow PEP 7 and good sense.
c2aad6e
to
fb9c865
Compare
@serhiy-storchaka Done! Thanks for the tip. PTAL |
FYI, I sent to @betswaliszewski about the CLA issue that I didn't create my account on bugs.python.org at that time. I created it today. And this issue will be solved. |
(CLA signed: http://bugs.python.org/user25975) |
fb9c865
to
c7bcf62
Compare
@serhiy-storchaka Ready for review! |
Objects/codeobject.c
Outdated
@@ -452,10 +452,15 @@ static PyObject * | |||
code_sizeof(PyCodeObject *co, void *unused) | |||
{ | |||
Py_ssize_t res; | |||
|
|||
res = _PyObject_SIZE(Py_TYPE(co)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If remove an empty line between declaration and assignment it is worth to merge them in one declaration with initialization.
Add an entry in And I think the test should be updated. We have no way to create |
c7bcf62
to
97a3450
Compare
@serhiy-storchaka Question:
I can not find current tests. It would be I am not familiar with the CPython codebase |
@corona10 You can found it at |
You can just add some large value to the result in |
Misc/NEWS
Outdated
@@ -10,6 +10,10 @@ What's New in Python 3.7.0 alpha 1? | |||
Core and Builtins | |||
----------------- | |||
|
|||
- bpo-12414: sys.getsizeof() on a code object now returns the sizes | |||
which includes the code struct and sizes of objects which it references | |||
patch by Dong-hee Na |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add periods after the sentences. Capitalize the first letter of "Patch".
4ec8b79
to
ecc22aa
Compare
@serhiy-storchaka Done! PTAL |
ecc22aa
to
9c037ee
Compare
Misc/ACKS
Outdated
@@ -1738,3 +1738,4 @@ evilzero | |||
Dhushyanth Ramasamy | |||
Subhendu Ghosh | |||
Sanjay Sundaresan | |||
Dong-hee Na |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names are ordered in rough alphabetical order of surnames. Your name should be placed together with the names starting with D or N (I don't know what is your given name and what is your surname).
9c037ee
to
272a62c
Compare
@serhiy-storchaka Thank you for your response. I updated the ACK file. |
Thank you for your contribution Dong-hee! Now you can cherry-pick b4dc6af to 3.6. |
bpo-12414: code_sizeof() update to take in account co_extras