cspotcode / cspotcode/py_typed_events
Misc optimization ideas
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
tuple instead of list for internal storage
- less memory? faster iteration?
- avoids the `list()` copying for emit, because it's immutable: any subscribe/unsubscribe is gonna create new tuple
Defer `WeakMap` removal to next (un)subscribe or emit event
store a `_dirty` flag which is set by finalizers
Rationale: if one instance binds to several events, then it's GC will trigger multiple finalizers in a row EDIT this is wrong because an instance will likely bind to any given event only once. If instance is bound to 3 events, that's 3 separate tuples.
Each emitter has `dead_weakref_count` which is total pending removals
`add_listener`, `remove_listener`, `emit` check when this number gets too high; perform batch removal
Avoids list getting bloated beyond a given threshold
Avoids a GC causing a ton of finalizers executed sequentially, duplicating effort
*Not a concern with set-backed `@broadcast` emitter*
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.