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 — bpo-39981: Default values for AST nodes by isidentical · Pull Request #19031 · python/cpython

Conversation

@isidentical

@isidentical isidentical commented Mar 16, 2020 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

https://bugs.python.org/issue39981

Sorry, something went wrong.

Uh oh!

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

All reactions
@isidentical
isidentical requested review from pablogsal and serhiy-storchaka March 16, 2020 20:06
pablogsal
pablogsal requested changes Mar 16, 2020
View reviewed changes
Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

Comment thread Parser/asdl_c.py Resolved

Uh oh!

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

@bedevere-bot bedevere-bot added the awaiting changes label Mar 16, 2020
@bedevere-bot

bedevere-bot commented Mar 16, 2020

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Mar 16, 2020

Copy link
Copy Markdown
Member

Some initial comments, without commenting on the approach itself.

@serhiy-storchaka should confirm that he is happy with this approach as he was working on some related functionality.

All reactions

Sorry, something went wrong.

Uh oh!

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

pablogsal
pablogsal reviewed Mar 16, 2020
View reviewed changes
Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

pablogsal
pablogsal reviewed Mar 16, 2020
View reviewed changes
Comment thread Doc/whatsnew/3.9.rst Resolved

Uh oh!

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

pablogsal
pablogsal reviewed Mar 16, 2020
View reviewed changes
Comment thread Lib/ast.py Outdated

@pablogsal pablogsal Mar 16, 2020

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.

I don't understand this function. When we set the node_type._field_defaults we could already place None or [] in there instead of this intermediary "?" and "*".

Sorry, something went wrong.

Uh oh!

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

All reactions

@isidentical isidentical Mar 17, 2020

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.

I dont think so, at least for lists. We are keeping _field_defaults as the same way we keep _fields, arrays of const char pointers. And then we construct a tuple from them and intern the values. I dont think it would be practical to do this with the original values.

Sorry, something went wrong.

Uh oh!

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

All reactions

@pablogsal pablogsal Mar 17, 2020 •
edited
Loading

Uh oh!

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

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.

I don't fully understand the problem. What is wrong with having _field_defaults as a list of the defaults themselves? When constructing the _field_defaults tuple you can do this logic already and populate them with None or the empty list or whatever, no?

For instance, in the make_type function you could set the defaults in the tuple instead of interning the strings.

Sorry, something went wrong.

Uh oh!

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

All reactions

@isidentical isidentical Mar 17, 2020

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.

Ah, that makes sense. Do you have an idea about what we should put if there is no field default, I think Ellipsis should work.

Sorry, something went wrong.

Uh oh!

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

All reactions

@pablogsal pablogsal Mar 17, 2020

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.

You don't need that if you use a dictionary instead of a tuple

Sorry, something went wrong.

Uh oh!

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

All reactions
@isidentical isidentical added the type-feature A feature request or enhancement label Mar 17, 2020
@isidentical

isidentical commented Mar 17, 2020

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting changes labels Mar 17, 2020
@bedevere-bot

bedevere-bot commented Mar 17, 2020

Copy link
Copy Markdown

Thanks for making the requested changes!

@pablogsal: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot
bedevere-bot requested a review from pablogsal March 17, 2020 07:21
isidentical and others added 3 commits March 18, 2020 12:15
@isidentical
bpo-39981: Default values for AST nodes
fd2cc00
@isidentical @pablogsal
apply suggestions from code review
6249514
Co-Authored-By: Pablo Galindo <[email protected]>
@isidentical
Do proper cleanups, increase reference of None, format switch
43fe55a
@isidentical
isidentical force-pushed the bpo-39981 branch 2 times, most recently from 9cdb15f to 0cbc2a8 Compare March 18, 2020 09:39
@isidentical
Keep field defaults inside of _field_defaults and recreate the mutabl…
5d033a1
…e ones
@isidentical
isidentical force-pushed the bpo-39981 branch from 0cbc2a8 to 5d033a1 Compare March 18, 2020 09:41
@isidentical

isidentical commented Apr 22, 2020

Copy link
Copy Markdown
Member Author

@serhiy-storchaka It would be awesome to have your review / thoughts on this before alpha cut.

All reactions

Sorry, something went wrong.

Uh oh!

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

@isidentical
Add AST._field_defaults for consistency
fb7990e
@isidentical

isidentical commented Jul 9, 2020

Copy link
Copy Markdown
Member Author

Closing this in favor of #21417

All reactions

Sorry, something went wrong.

Uh oh!

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

@isidentical isidentical closed this Jul 9, 2020
@isidentical isidentical mentioned this pull request Apr 10, 2022
Default values for AST Nodes #84162
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
@pablogsal pablogsal Awaiting requested review from pablogsal

Uh oh!

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

Assignees

No one assigned

Labels

awaiting change review type-feature A feature request or enhancement

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.

3 participants

@isidentical @bedevere-bot @pablogsal
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.