#18627: Remove django-core uses of Model pre_init and post_init
-------------------------------------+-------------------------------------
     Reporter:  jdunck               |                    Owner:  jdunck
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |                  Version:  1.4
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:                       |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 If this would be easy to do in the field itself that would be nice.
 Unfortunately any approach where a method is called for each field on
 model init is immediately a no-go, as the performance hit is substantial.

 What is done in the ticket is basically caching the information which
 fields has a method that do something.

 If there is a way to do field on-init calls with properties or something
 similar, then that would be neat. Still, if I understand correctly one
 can't do the post_init stuff at assignment time.

 It is true the current approach is a little ugly. One the other hand model
 `__init__` speed is important.

 With carefully crafted signal receiver caching we can actually get same
 performance (if not even little better) than given by this idea, but I
 haven't seen too much interest in #16679 from other core devs... In
 addition, #16679 or something similar is needed for efficient inherited
 signals.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18627#comment:4>
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 https://groups.google.com/groups/opt_out.


Reply via email to