[Libre-soc-bugs] [Bug 713] PartitionedSignal enhancement to add partition-context-aware lengths

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sat Oct 9 02:14:32 BST 2021


--- Comment #49 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Jacob Lifshay from comment #43)
> (In reply to Luke Kenneth Casson Leighton from comment #40)
> > (In reply to Jacob Lifshay from comment #36)
> > > we can deduplicate expressions ourselves pretty easily:
> > 
> > ooo niiiice, that's really valuable and exciting.
> > 
> > i bet a similar trick would be possible to deploy for autocreating
> > intermediary temporary Signals.
> > 
> > can you drop this into nmutil?
> sure! Python's GC just had a heart-attack at the sight of it, but oh well.
> Good thing we don't have long-running programs that need PartitionedSignal.


I also added support for having globals go into the key, since we need to
include the scoped globals there:

my_global = 42

@deduped(global_keys=[lambda: my_global])
def fn_with_global(a, *, b=1):

so we could use it like:

class PartitionedSignal(...):
    def __add__(self, rhs):

though to improve deduping, we may want to do:
class PartitionedSignal(...):
    def _do_add_impl(*args):
        # put __add__ and __radd__'s guts here

    def _do_add(*args):
        args = list(args)
        # consistent argument order to handle commutativity
        return PartitionedSignal._do_add_impl(*args)

    def __add__(self, other):
        return PartitionedSignal._do_add(self, other)

    def __radd__(self, other):
        return PartitionedSignal._do_add(other, self)


I also added support for opportunistically using weakref.

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

More information about the libre-soc-bugs mailing list