#16679: Speed up signals by caching the reveicers per sender -------------------------------------+------------------------------------- Reporter: akaariai | Owner: nobody Type: | Status: new Cleanup/optimization | Version: 1.3 Component: Database layer | Resolution: (models, ORM) | Triage Stage: Accepted Severity: Normal | Needs documentation: 0 Keywords: | Patch needs improvement: 1 Has patch: 1 | UI/UX: 0 Needs tests: 0 | Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by Suor): About failures: it's tests that wrong here, they rely on `.receivers` property being list of receivers while I use more complex structure. Sure adjusted tests should be added to my patch, I was just giving a try at a moment. About worst case: Yeah, the worst case is than combine() is needed. It still has linear complexity, not so bad. About caching: in fast-signals2.diff you use both `sender_receivers_cache` and `sender_no_receivers_cache`. The latter seems superfluous you can just store [] in the former, and then use something like: {{{ if not self.receivers: return [] if sender in self.sender_receivers_cache: receivers = self.receivers_cache[sender] else: receivers = self.receivers_cache[sender] = self._receivers_for_sender(sender) return deref(receivers) }}} I also dropped `.use_caching` property. What can be a reason not to? Just cache always since it don't change any behavior. -- Ticket URL: <https://code.djangoproject.com/ticket/16679#comment:10> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.