Skip to content
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-36876: Moved Parser/listnode.c statics to interpreter state. #16328

Merged
merged 2 commits into from
Nov 7, 2019
Merged

bpo-36876: Moved Parser/listnode.c statics to interpreter state. #16328

merged 2 commits into from
Nov 7, 2019

Conversation

vsajip
Copy link
Member

@vsajip vsajip commented Sep 22, 2019

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly LGTM

I have left just a few small suggestions to consider.

Include/internal/pycore_pystate.h Outdated Show resolved Hide resolved
Include/internal/pycore_pystate.h Outdated Show resolved Hide resolved
/*
* See bpo-36876: miscellaneous ad hoc statics have been moved here.
*/
struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think there will be any other parser/compiler-related state to move to PyInterpreterState then consider making this struct stand-alone and perhaps even creating pycore_compiler.h (or pycore_parser.h) for it. That way the code doesn't get too cluttered.

atbol = 1;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();

interp->parser_data.listnode_data.level = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to point to the advantage of having stand-alone structs for places like this (so there isn't so much going on with each line). However, I actually kind of like how the line captures the indirection clearly. :)

@vsajip vsajip merged commit 9def81a into python:master Nov 7, 2019
@vsajip vsajip deleted the fix-36876-parser-listnode branch November 7, 2019 10:08
@vstinner
Copy link
Member

vstinner commented Nov 7, 2019

interp = _PyInterpreterState_GET_UNSAFE(); 

You can add listnode or parser variable to avoid having to write "interp->parser.listnode". But for that, you need to name the structure in pycore_pystate.h.

@vsajip
Copy link
Member Author

vsajip commented Nov 7, 2019

I'm not quite sure what you mean. The change was specifically to move those variables into the interpreter state rather than stand-alone variables, as they were previously.

@vstinner
Copy link
Member

vstinner commented Nov 8, 2019

I suggest to add parser = &interp->parser; and then use parser instead of interp. Or something similar with listnode.

@vsajip
Copy link
Member Author

vsajip commented Nov 8, 2019

Ah, OK, I understand now :-)

Not sure what an additional variable buys in this case. I agree, if readability were adversely affected, it would be worth doing. As it is, it seems readable enough.

@vstinner
Copy link
Member

It was just a minor remark for readability. You're free to ignore it ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants