#29215: Document potential change to behaviour of QuerySet methods when 
upgrading
to Python 3.6
-------------------------------------+-------------------------------------
     Reporter:  Matt Fisher          |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Documentation        |                  Version:  2.0
     Severity:  Normal               |               Resolution:
     Keywords:  documentation        |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * cc: Simon Charette (added)


Comment:

 This behavior has little to do with Python 3.6 itself.

 If you had query performing better on Python 2.7 than on Python 3 it's
 probably because you weren't using
 
[https://docs.python.org/2/using/cmdline.html?highlight=pythonhashseed#cmdoption-r
 a random hash seed] which is the default on Python 3. In other words, you
 were relying on a stable hash seed to build queries in a way that
 PostgreSQL query planner's would correctly optimize. If you had updated
 from 2.7 to Python 3.5 instead you would have hit the slow query issue
 from time to time when the interpreter chose an hash seed that made
 `list({'b__in', 'a'}) == ['b__in', 'a']`. In some way Python 3.6 allows
 you to reliably build your `WHERE` statement through kwargs ordering while
 it wasn't possible before.

 I guess we could add a section about the fact Python 3 has random hash
 seeding on by default and that may break code making assumptions about
 unordered data structures ordering. Maybe we should also suggest running
 Python 2.7 with the `-R` flag on when porting code?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29215#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/068.91974fd3de7338a81ffd249bbf4446ce%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to