-
Notifications
You must be signed in to change notification settings - Fork 85
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
Speed up on_trait_change, part II #1491
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM with one question.
type=lnw.type, | ||
priority=priority, | ||
deferred=deferred, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make the same changes to these three traits as well? Is that planned in a subsequent PR? type
and deferred
don't seem to have any static trait change handlers hooked up to them but priority
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subsequent PR. For type
and deferred
, it's messy, as you'll see when the next PR lands. :-) priority
is mostly the same as in this PR, except that it's handled differently at ListenerGroup
level.
@rahulporuri Thanks for reviewing! Will merge this PR and then merge the main branch into #1492. |
Context: This PR follows on from #1490. It's part of a larger effort to identify and ameliorate performance bottlenecks in the on_trait_change, while not changing the
on_trait_change
behaviour.This PR changes the way that
ListenerItem
s are initialised. Previously, in theon_trait_change
method:ListenerParser
created a tree ofListenerBase
instances (ListenerItem
s andListenerGroup
s),handler
,wrapped_handler_ref
anddispatch
traits were set on the root node of the treeThose static trait-change handlers are one cause of slowness in a large Traits-using system.
With this PR, the
ListenerParser
takes care of provisioning all theListenerItem
s at creation time, instead of propagating the changes down afterListenerItem
creation.This PR gets us partway to making the
ListenerItem
andListenerGroup
classes not need to be traited classes at all. I plan to make at least one more PR to complete that process.This PR should be reviewable commit by commit: all tests should pass at each commit.