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

Streamline family syntax in Tools/cases_generator #106706

Closed
gvanrossum opened this issue Jul 13, 2023 · 11 comments
Closed

Streamline family syntax in Tools/cases_generator #106706

gvanrossum opened this issue Jul 13, 2023 · 11 comments
Labels

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Jul 13, 2023

The syntax to designate a family currently looks like this:

        family(store_subscr, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = {
            STORE_SUBSCR,
            STORE_SUBSCR_DICT,
            STORE_SUBSCR_LIST_INT,
        };

Here the store_subscr "family name" is redundant (and in fact we even had one case where it was incorrect).

I propose to change it to be more similar to the pseudo syntax, so it will become

        family(STORE_SUBSCR, INLINE_CACHE_ENTRIES_STORE_SUBSCR) = {
            STORE_SUBSCR_DICT,
            STORE_SUBSCR_LIST_INT,
        };

This should be a straightforward change to the parser and code generator in Tools/cases_generator.

Linked PRs

@danik292
Copy link

Where I find thet code?

@gvanrossum
Copy link
Member Author

In Tools/cases_generator/. The example is in Python/bytecodes.c.

kgdiem added a commit to kgdiem/cpython that referenced this issue Jul 13, 2023
@kgdiem
Copy link
Contributor

kgdiem commented Jul 13, 2023

I started working on this here: https://github.com/kgdiem/cpython/tree/streamline-family-syntax

I think the correct course of action to change the validations check_families[1] (decrement member length requirement, ensure name is in the macro instructions) and make some simple updates to write_metadata[2] ingenerate_cases.py.

Is that correct?

[1] https://github.com/python/cpython/blob/main/Tools/cases_generator/generate_cases.py#L809
[2] https://github.com/python/cpython/blob/main/Tools/cases_generator/generate_cases.py#L1171

@gvanrossum
Copy link
Member Author

@kgdiem You got it!

@kgdiem
Copy link
Contributor

kgdiem commented Jul 13, 2023

@kgdiem You got it!

Awesome! I had one question about changing one of the tests in my PR but I saw you opened another issue wrt them being broken ...

#105540

@gvanrossum
Copy link
Member Author

gvanrossum commented Jul 13, 2023

If you are ready for a review of your code, just make a PR and CC me. [Sorry, realized you already did. Reviewing now.]

gvanrossum pushed a commit to gvanrossum/cpython that referenced this issue Jul 15, 2023
gvanrossum pushed a commit that referenced this issue Jul 16, 2023
From `family(opname, STRUCTSIZE) = OPNAME + SPEC1 + ... +  SPECn;`
to `family(OPNAME, STRUCTSIZE) = SPEC1 + ... + SPECn;`
@gvanrossum
Copy link
Member Author

@kgdiem Thanks for your contribution! You're welcome to help out more any time.

@kgdiem
Copy link
Contributor

kgdiem commented Jul 17, 2023

@kgdiem Thanks for your contribution! You're welcome to help out more any time.

Thanks! I'm interested in spending 5-10 hours/week working on Python/Python ecosystem but having some trouble finding another issue I can pick up.

@gvanrossum
Copy link
Member Author

Thanks! I'm interested in spending 5-10 hours/week working on Python/Python ecosystem but having some trouble finding another issue I can pick up.

Cool. May I inquire what motivates you to do this? And what kind of issues are you looking for? Can they involve C code?

@kgdiem
Copy link
Contributor

kgdiem commented Jul 17, 2023

May I inquire what motivates you to do this?

I enjoy it! I code as a hobby (and professionally) and want to do something beyond web development; high perf, systems programming, applied CS, etc

And what kind of issues are you looking for? Can they involve C code?

Ya. I started looking at the last issue you'd opened (gh-106608) but was a bit intimidated and was trying to find something "easier" / more in my traditional wheelhouse.

In thinking about my reply here, re-reviewing the issue & related the code, I'm pretty confident and am going to give it a shot. I'll reach out over there if I need any help.

Thanks again.

@gvanrossum
Copy link
Member Author

Cool, see you at that issue. Be sure not to bang your head against the wall for too long -- ask for help before it starts bleeding! :-)

gvanrossum added a commit that referenced this issue Jul 18, 2023
These repair nits I found in PR gh-106798 (issue gh-106797) and in PR gh-106716 (issue gh-106706).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants