* eq * flatten * shape * like * cat * functions/classes for walking data structures (__iter__/__next__ and yield) https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/add/singlepipe.py;h=fe052be72a3e70fde85e56058cf708ea9e7cd341;hb=25a0ec563bd7837b43a1d04036b2a5945c97023b#l291 properly evaluate if eq and flatten are needed as globals, or if they are better placed into a class. benefits of eq and flatten being globals is that they can accept lists (or tuples, or anything supporting python Sequence pattern, including generators and iterators). like needed for creating similar object to one that already exists.
occurred to me that eq is equivalent to the pattern of the python operator module. as such this would tend to suggest a name for a module where it could live: nmutil.operator. from nmutil.operator import eq this would form the pattern for additional "global" functions present in Value (such as shape, implies and part). flatten is... different, in that it is already in nmigen.tools, which in turn assumes that the nmigen object is iterable (isinstance(x, Iterable) and that in turn implies it should have an __iter__ (etc. etc.). except, the version in nmigen.tools fails because Record doesn't have an __iter__. patch for Record created (attached)
Created attachment 8 [details] provides Record.__iter__
(In reply to Luke Kenneth Casson Leighton from comment #1) > as such this would tend to suggest a name for a module where it could > live: nmutil.operator. > > from nmutil.operator import eq moved eq, shape and cat to nmoperator.py temporarily. also the two visitor classes.