[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 16:29:19 BST 2023


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

--- Comment #150 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Dmitry Selyutin from comment #148)
> I forgot to mention 1 step in roadmap: we miss support for dataclasses. I'll
> add it too. I think this will be a bit trickier to make it generic, though,
> since dataclasses do not inherit from some special class; we, however, do.

just use:
https://docs.python.org/3.7/library/dataclasses.html#dataclasses.is_dataclass
and then call dataclasses.fields since that avoids needing to raise a
typeerror, which is kinda slow iirc

also you can check for plain_data instances (feel free to add a
plain_data.is_plain_data() function based off plain_data.fields(), since
creating exceptions is kinda slow):
https://git.libre-soc.org/?p=nmutil.git;a=blob;f=src/nmutil/plain_data.py;h=7bde6ba2f27ff3786beab9c036019337e36bbfe7;hb=4bf2f20bddc057df1597d14e0b990c0b9bdeb10e#l298

nmutil should probably be an optional import:
try:
    # renamed to not conflict with dataclasses
    from nmutil.plain_data import is_plain_data as _is_plain_data, fields as
_plain_data_fields
except ImportError:
    def _is_plain_data(v):
        return False
    # _plain_data_fields not needed since _is_plain_data always returns False

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


More information about the libre-soc-bugs mailing list