Skip to content

Commit a492c97

Browse files
committed
refactor: mke Date class use __slots__
This should be the last slotting for a while. Instrumenting roundup-admin and the Client class (running under the waitress wsgi server) shows object count output similar to: [(('IssueClass', 'roundup.backends.back_anydbm'), 128), (('Session', 'roundup.cgi.client'), 128), (('Mailer', 'roundup.mailer'), 128), (('Password', 'roundup.password'), 220), (('LiberalCookie', 'roundup.cgi.client'), 241), (('Database', 'roundup.backends.back_anydbm'), 256), (('FileClass', 'roundup.backends.back_anydbm'), 256), (('Number', 'roundup.hyperdb'), 256), (('PythonExpr', 'roundup.cgi.PageTemplates.PythonExpr'), 274), (('Proptree', 'roundup.hyperdb'), 276), (('Role', 'roundup.security'), 384), (('PathExpr', 'roundup.cgi.PageTemplates.Expressions'), 630), (('Class', 'roundup.backends.back_anydbm'), 640), (('SubPathExpr', 'roundup.cgi.PageTemplates.Expressions'), 645), (('Date', 'roundup.hyperdb'), 678), (('Link', 'roundup.hyperdb'), 934), (('Multilink', 'roundup.hyperdb'), 1024), (('Permission', 'roundup.security'), 6784), (('TruthDict', 'roundup.support'), 6795), (('PrioList', 'roundup.support'), 8192), (('Date', 'roundup.date'), 8610)] where each row is a tuple of (class, module) and the count of the number of object of that class sorted by number of objects. I think the major classes that meet the criteria below are all __slotted__ at this point: Is a native roundup class and not a subclass (e.g. LiberalCookie is subclass of http.cookies.SimpleCookie) Does not touch the database (not hyperdb or backend) Is not part of templating Is not a top level class that may need runtime attributes/methods overwritten e.g Session/Mailer/Password Some of the excluded classes can be slotted, but they are not low hanging fruit and requires more class heirarchy changes or more extensive testing.
1 parent 6e43272 commit a492c97

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

roundup/date.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ class Date:
324324
>>> test_fin(u)
325325
'''
326326

327+
__slots__ = ("year", "month", "day", "hour", "minute", "second",
328+
"_", "ngettext", "translator")
329+
327330
def __init__(self, spec='.', offset=0, add_granularity=False,
328331
translator=i18n):
329332
"""Construct a date given a specification and a time zone offset.

0 commit comments

Comments
 (0)