[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Mon Jun 19 21:40:37 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=1094

--- Comment #192 from Dmitry Selyutin <ghostmansd at gmail.com> ---
And, with a dataclass added...

@dataclasses.dataclass()
class A:
    a: int
    b: "list[int]"

items = (
    {("a", 1): 3.4, 2: {5, 6}},
    {3: A(5, [12, 3])},
)
for (item, path) in walker(items):
    with visitor(item, path=path):
        pass


...that's what we get:

     [0] => {('a', 1): 3.4, 2: {5, 6}}
         [0][('a', 1)] => 3.4
         [0][2] => {5, 6}
             [0][2][5] => 5
             [0][2][6] => 6
     [1] => {3: A(a=5, b=[12, 3])}
         [1][3] => A(a=5, b=[12, 3])
             [1][3]['a'] => 5
             [1][3]['b'] => [12, 3]
                 [1][3]['b'][0] => 12
                 [1][3]['b'][1] => 3


That said, I still think that we must somehow designate that in case of
dataclass we access not by index but by an attribute. With that in mind,
perhaps the path should be somewhat more flexible than it is, and have
different types: AttributePath, DictItemPath, SetPath and IndexPath. This way
the repr can be handled.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list