#20880: Split clone() to clone() and pre_next_op()
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:                       |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by akaariai):

 * needs_docs:   => 0
 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * stage:  Unreviewed => Accepted


Old description:

> QuerySet and Query clone() methods are doing more than just cloning, they
> are also doing set up for next operation, changing the class of the clone
> if requested, and even throwing away some attribute values.
>
> To make the code a bit more readable the clone() the preparation for next
> op should be splitted away to pre_next_op() method. This also allows
> creating inplace querysets that work precisely like full-clone querysets
> (inplace queryset doesn't do cloning at all). This again allows speeding
> up certain internal operations (like model.save() and
> prefetch_related()), and also allows users to optimise heavy-to-create
> querysets by avoiding clone() overhead.
>
> Patch available from
> https://github.com/akaariai/django/tree/splitted_clone. The inplace
> queryset used for Model.save_base() speeds up model.save() by about 20%
> for a simple m = Model.objects.get(); m.save() benchmark. There are other
> places where similar optimisations could be used. Prefetch speedup is
> tracked in ticket #20577.

New description:

 QuerySet and Query clone() methods are doing more than just cloning, they
 are also doing set up for next operation, changing the class of the clone
 if requested, and even throwing away some attribute values.

 To make the code a bit more readable the clone() method should be splitted
 to clone() part and pre_next_op() part. This also allows creating inplace
 querysets that work precisely like full-clone querysets. A queryset is
 called inplace if it doesn't do cloning at all between operations. This
 again allows speeding up certain internal operations like model.save() and
 prefetch_related(), and also allows users to optimise heavy-to-create
 querysets by avoiding clone() overhead.

 Patch available from
 https://github.com/akaariai/django/tree/splitted_clone. The inplace
 queryset used for Model.save_base() speeds up model.save() by about 20%
 for a simple m = Model.objects.get(); m.save() benchmark. There are other
 places where similar optimisations could be used. Prefetch speedup is
 tracked in ticket #20577.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20880#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.363b4301b044604eaf9e023b768a810f%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to