#26095: Same behaviour of dict.items and defaultdict.items in DTL
-------------------------------------+-------------------------------------
     Reporter:  kbr                  |                    Owner:  kbr
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Template system      |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  templates dict       |             Triage Stage:
  defaultdict                        |  Unreviewed
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by kbr):

 Well, the isinstance()-call is about 4 times slower than the direct access
 (d[bit] alone takes about 98 ns. (on a dict with a single entry)).
 {{{
 %%timeit
 if isinstance(d, defaultdict):
     pass
 res = d[bit]

 1000000 loops, best of 3: 378 ns per loop
 }}}

 Whether this is a real bottleneck depends how often Variable.resolve gets
 called and - may be more important - other time consuming parts of the
 application. Will try djangobench the next days. Thank you for the review
 so far.

--
Ticket URL: <https://code.djangoproject.com/ticket/26095#comment:6>
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/061.4cc365c6dc45c5ef3e00b029c97824cd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to