Mercurial > p > roundup > code
comparison roundup/date.py @ 8473:a73ac3752ac5
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 03 Nov 2025 12:42:48 -0500 |
| parents | 2bf0c4e7795e |
| children | 9c3ec0a5c7fc |
comparison
equal
deleted
inserted
replaced
| 8472:224ccb8b49ca | 8473:a73ac3752ac5 |
|---|---|
| 322 <Date 2003-07-01.00:00:00.000> | 322 <Date 2003-07-01.00:00:00.000> |
| 323 | 323 |
| 324 >>> test_fin(u) | 324 >>> test_fin(u) |
| 325 ''' | 325 ''' |
| 326 | 326 |
| 327 __slots__ = ("year", "month", "day", "hour", "minute", "second", | |
| 328 "_", "ngettext", "translator") | |
| 329 | |
| 327 def __init__(self, spec='.', offset=0, add_granularity=False, | 330 def __init__(self, spec='.', offset=0, add_granularity=False, |
| 328 translator=i18n): | 331 translator=i18n): |
| 329 """Construct a date given a specification and a time zone offset. | 332 """Construct a date given a specification and a time zone offset. |
| 330 | 333 |
| 331 'spec' | 334 'spec' |
