GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-100719: Remove the `co_nplaincellvars` field from code objects. by markshannon · Pull Request #100721 · python/cpython

Conversation

@markshannon

@markshannon markshannon commented Jan 3, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Removes a redundant field

  • Issue: Code objects, function objects and generator object contain quite a lot of redundant information #100719

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
Remove the co_nplaincellvars field from code objects.
6467497
@markshannon
markshannon requested a review from iritkatriel as a code owner January 3, 2023 16:40
@bedevere-bot bedevere-bot added the awaiting core review label Jan 3, 2023
@bedevere-bot bedevere-bot mentioned this pull request Jan 3, 2023
Code objects, function objects and generator object contain quite a lot of redundant information #100719
Closed
@markshannon
markshannon requested a review from ericsnowcurrently January 3, 2023 16:40
markshannon added 2 commits January 3, 2023 16:41
@markshannon
Add news
8713010
@markshannon
Merge branch 'main' into trim-code-object
3309eb2
iritkatriel
iritkatriel reviewed Jan 3, 2023
View reviewed changes
Comment thread Objects/typeobject.c
// Look for __class__ in the free vars.
PyTypeObject *type = NULL;
int i = co->co_nlocals + co->co_nplaincellvars;
int i = PyCode_GetFirstFree(co);

@iritkatriel iritkatriel Jan 3, 2023

Copy link
Copy Markdown
Member

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.

Py_ssize_t?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Jan 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

This should be an int. I'll change PyCode_GetFirstFree.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@obataku obataku Jan 6, 2023

Copy link
Copy Markdown

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.

@markshannon why should it be int?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wrongnull reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Objects/frameobject.c
/* Free vars have not been initialized -- Do that */
PyObject *closure = ((PyFunctionObject *)frame->f_funcobj)->func_closure;
int offset = co->co_nlocals + co->co_nplaincellvars;
int offset = PyCode_GetFirstFree(co);

@iritkatriel iritkatriel Jan 3, 2023

Copy link
Copy Markdown
Member

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.

Py_ssize_t?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/compile.c

if (co->co_nfreevars) {
int i = co->co_nlocals + co->co_nplaincellvars;
int i = PyCode_GetFirstFree(co);

@iritkatriel iritkatriel Jan 3, 2023

Copy link
Copy Markdown
Member

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.

Py_ssize_t?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@markshannon
Fix return type.
49ca044
iritkatriel
iritkatriel approved these changes Jan 4, 2023
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Jan 4, 2023
@markshannon
markshannon merged commit 15aecf8 into python:main Jan 4, 2023
@bedevere-bot bedevere-bot removed the awaiting merge label Jan 4, 2023
@markshannon
markshannon deleted the trim-code-object branch January 12, 2023 15:38
This was referenced Feb 20, 2024
gh-115653: Add docs for the PyCode_GetFirstFree and correct return type for the PyCode_GetNumFree #115654
Merged
Make PyCode_GetFirstFree a PEP-689 unstable API #115756
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
+1 more reviewer
@obataku obataku obataku left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@markshannon @iritkatriel @obataku @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.