You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These doubly-nested sequences increase the complexity of handling for node fields because everywhere general node-processing code is required, there need to be two nested type checks and a factored-out function to handle the otherwise-identical code for the first and second levels of sequences. This is especially painful when generators are involved because on Python < 3.2, without yield from, there's no good way to factor code out of generators.
I would propose that node fields should be defined to be either individual nodes or sequences of nodes, nothing else. This will make the zipper code simpler and faster and help other places similar code is required, like #259. Nodes that currently contain nested sequences should either have the nested sequences split into multiple fields, like the stdlib AST module does for Dict,
Changing the Dict interface to be similar with Python's builtin ast module sounds like a good enhancement to me, there's no arguing against that.
What do you mean by nodes or sequences of nodes, nothing else? Two different nodes can have either nodes or sequences of nodes, depending on their type. Hope that I'm not understanding something else here.
I mean specifically that for all the fields of a node that contain other nodes (everything currently labeled by _astroid_fields), they should contain either a direct reference to a node or a sequence of nodes, not any other possible Python object, not non-node objects other than sequences, not nested sequences, not dicts, etc.
Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen?
Some of the nodes currently contain fields that are doubly-nested sequences, usually tuples inside lists. For instance, look at Dict nodes:
These doubly-nested sequences increase the complexity of handling for node fields because everywhere general node-processing code is required, there need to be two nested type checks and a factored-out function to handle the otherwise-identical code for the first and second levels of sequences. This is especially painful when generators are involved because on Python < 3.2, without
yield from
, there's no good way to factor code out of generators.I would propose that node fields should be defined to be either individual nodes or sequences of nodes, nothing else. This will make the zipper code simpler and faster and help other places similar code is required, like #259. Nodes that currently contain nested sequences should either have the nested sequences split into multiple fields, like the stdlib AST module does for Dict,
or have new subnodes defined that contain the individual nodes.
The text was updated successfully, but these errors were encountered: