Ticket #3245 enhancement closed worksforme
__slots__ in Deferred class?
|Reported by:||Mekk||Owned by:|
|Cc:||glyph, radix, mgeisler||Branch:||
(diff, github, buildbot, log)
|Author:||mgeisler, Mekk, exarkun||Launchpad Bug:|
Description (last modified by exarkun) (diff)
Programs which use a lot of Deferreds could benefit from __slots__.
Simple test I did proved, that the program which created huge list of empty Deferreds had its memory usage (both RSS anv VSS) halved after such a change (longer post on the mailing list)
Important impact: d.some_unknown_attribute=something will fail. What can be ... a good thing, as it would catch some cases of deferred being mistakenly used as if it was real object.
The change is fairly small (defer.py):
class Deferred(object): __slots__ = ['debug', 'callbacks', 'called', 'paused', 'result', 'timeoutCall', '_runningCallbacks', '_debugInfo']