#37125: Use __new__ to sanitize TaskResult instead of __post_init__ to half 
memory
usage
-------------------------------------+-------------------------------------
     Reporter:  Johannes Maron       |                    Owner:  zky
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Tasks                |                  Version:  dev
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by zky):

 Thanks for the great catch, Jacob! Indeed, after running a quick test
 locally, I confirmed exactly what you pointed out—modifying kwargs inside
 __new__ doesn't actually take effect for the initialization.

 Given this, would introducing a classmethod factory be a viable
 alternative to solve the original memory issue?Replying to [comment:6
 Jacob Walls]:
 > I think the bench incorrectly implements `__new__()`. It looks like the
 `kwargs` are mutated in place, but they're actually re-bound and
 discarded:
 >
 > {{{#!py
 > >>> def a(**kwargs): return kwargs
 > ...
 > >>> kw = {}
 > >>> inner = a(**kw)
 > >>> inner is kw
 > False
 > }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37125#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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019e74326834-f2a0bdc7-d245-4fdb-8c10-8655f77b0dee-000000%40eu-central-1.amazonses.com.

Reply via email to