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

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Jun 18 20:14:20 BST 2023


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

--- Comment #166 from Dmitry Selyutin <ghostmansd at gmail.com> ---
Oh, by the way, I just recalled that tuples et al. simply yield stuff from
collection upon walking by default.

class Walker(dispatcher.Dispatcher, metaclass=WalkerMeta):
    @dispatcher.Hook(tuple, list, set, frozenset)
    def dispatch_sequence(self, instance):
        for item in instance:
            yield item
            yield from self(item)

dicts and dataclasses, on the other hand, yield key too. Should the dispatcher
look like this instead?

    @dispatcher.Hook(tuple, list, set, frozenset)
    def dispatch_sequence(self, instance):
        for (index, item) in enumerate(instance):
            yield (index, item)
            yield from self(item)

Also, whilst we're at it, we could perhaps support namedtuple default hook
(yielding keys too I think).
I'd like to listen to your opinion, folks, on these two.

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


More information about the libre-soc-bugs mailing list