-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: New SignalGroup that does not subclass SignalInstance #269
Conversation
CodSpeed Performance ReportMerging #269 will degrade performances by 23.5%Comparing Summary
Benchmarks breakdown
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #269 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 1852 1898 +46
=========================================
+ Hits 1852 1898 +46 ☔ View full report in Codecov by Sentry. |
@getzze, if you have a moment to take a look, I would appreciate it! This implements your proposal from #262 (comment) It does not yet add aliases or prefixes as you've done in other PRs (you can do those in another PR if you still want them after this) |
Some idea for later (for instance for the nested events): add a method to SignalRelay to merge two SignalRelays: def update(self, relay: SignalRelay, take_over: bool = True):
self._signals.update(relay._signals)
self._sig_was_blocked.update(relay._sig_was_blocked)
for sig in relay._signals.values():
if take_over:
sig.disconnect(relay._slot_relay)
sig.connect(self._slot_relay, check_nargs=False, check_types=False, unique=True) |
yeah, this is what I was getting at in #269 (comment) I agree, there should be a guaranteed public property or method. my inclination would be an |
I was proposing functions and not methods to avoid any name conflict. But if the method name starts with The good thing about We can always add possibility to use aliases, which are useful even after this PR, to alias a private field to a public name. |
thanks @getzze! yeah I agree. feels tough to make this rather tiny-but-important decision. I might ping @jni for his thoughts on this: Juan, we all like the idea of
|
I think I like 3 better.
Somebody mentioned the example of `pandas` that I think is a good model: you can access ALL the columns by key, like `events["name"]`, and by attribute, only the columns with a well-behaved (no space) and non-conflicting name.
…On 15 February 2024 21:43:16 GMT+00:00, Talley Lambert ***@***.***> wrote:
thanks @getzze! yeah I agree. feels tough to make this rather tiny-but-important decision. I might ping @jni for his thoughts on this:
Juan, we all like the idea of `events.all.connect` ... but `all` still has the possibility of name conflict (as you pointed out before). The current PR allows the user to change the name `all` to something else if they want to use it for themselves (thereby avoiding the conflict) ... but then we have the problem of a third party wanting to know how to get at the aggregate/relay connector. That leads to a desire to have a permanent public name like `events.all_psygnals.connect` or `events.get_relay().connect`, which are uglier, to be sure. What do you think? some options:
1. stick with `events.all` by default, but allow the user to pick their own public name, and to hell with anyone else who receives the object 😂 _(this is probably a no... since magicgui for example needs to know how to get at the relay)_
2. keep `events.all`, and allow user-overrides, *and* add a permanent safe public name like `events.all_psygnals` (name suggestions welcome)
3. use `events.all`, and if someone has a dataclass with a field named `all`, then they *must* access it using `group['all']`. because `events.all` will always point to the relay.
4. don't use `events.all`, just go with one permanent ugly public name `events.all_psygnals` that's unlikely to ever conflict with a dataclass field.
--
Reply to this email directly or view it on GitHub:
#269 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
yep, and combined with the warning at class creation that you stubbed out in #269 (review) ... i think there will be no surprises |
I like 3 also, by a fair margin, so I am happy that we are all in agreement. 😊 |
implemented in 47bf3ae |
ok! this one is going in :) Thanks all for the helpful discussion. Huge thanks to @getzze for getting this name-conflict discussion started in #260, and for proposing the solution that was ultimately implemented here in #262 (comment). It's not often that someone comes along and dives deep enough to understand the existing codebase and provides very insightful and productive suggestions. I hope you don't mind that I ran with that idea and implemented it here (it was a big change that I wanted to consider carefully), and I hope that you'll continue contributing improvements :) |
this will be released as v0.10.0rc0 for a week or so before release |
Ahahah, likewise, it's not every time that developers include contributors, who know less about the project, to make big changes.
I have others PRs to propose ;)
…On 16 February 2024 14:54:46 GMT+00:00, Talley Lambert ***@***.***> wrote:
ok! this one is going in :)
Thanks all for the helpful discussion. Huge thanks to @getzze for getting this name-conflict discussion started in #260, and for proposing the solution that was ultimately implemented here in #262 (comment). It's not often that someone comes along and dives deep enough to understand the existing codebase and provides very insightful and productive suggestions. I hope you don't mind that I ran with that idea and implemented it here (it was a big change that I wanted to consider carefully), and I hope that you'll continue contributing improvements :)
--
Reply to this email directly or view it on GitHub:
#269 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
This PR implements the idea proposed by @getzze in #267
Notable changes in this PR:
SignalGroup
is no longer aSignalInstance
subclass. All methods that used to be accessible onSignalGroup
(such asconnect
,disconnect
,blocked
, etc...) should now be accessed on the signal relay atgroup.all
.SignalGroup.__getitem__
, in addition to__getattr__
.__iter__
(to list all signal names),__len__
(number of signals),__getitem__
(get a signal). But does not currently subclassabc.Mapping
(so it does not haveitems()
,values()
,keys()
)Deprecations:
connect
, etc) on a SignalGroup is deprecated, (but still works for now). Usinggroup.all
instead.signals
on a group instance (to get a dict of name->signal instance) is deprecated. Instead use a combination of Mapping methods__iter__
and__getitem__
/__getattr__
Breaking:
SignalGroup
no longer inheritsSignalInstance
, the semantics of the__len__
method on a signal group changes; it now returns the number of signal names, not the number of connected slots. This is probably the main breaking change that I can't deprecate.closes #260
closes #267