#20757: A more Object-Oriented URLResolver
-----------------------------+------------------------------------
     Reporter:  fcurella     |                    Owner:  nobody
         Type:  New feature  |                   Status:  new
    Component:  Core (URLs)  |                  Version:  master
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  0
  Needs tests:  1            |  Patch needs improvement:  1
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+------------------------------------

Comment (by UloPe):

 I've done a quick benchmark. The code and raw results can be found here:
 https://gist.github.com/ulope/a63aff42f51b08181f72#file-results-txt

 Here is a table of the results (n=1000000):

 ||= Python =||= operation =||= datastructure =||= time              =||
 || CPy 2.6  || instantiate || tuple           || 0.243867874146      ||
 ||          || instantiate || namedtuple      || 0.791953086853      ||
 ||          || access      || tuple           || 0.342396020889      ||
 ||          || access      || namedtuple      || 1.09635186195       ||
 ||          ||             ||                 ||                     ||
 || CPy 2.7  || instantiate || tuple           || 0.300357103348      ||
 ||          || instantiate || namedtuple      || 0.817892074585      ||
 ||          || access      || tuple           || 0.397746801376      ||
 ||          || access      || namedtuple      || 1.12735199928       ||
 ||          ||             ||                 ||                     ||
 || CPy 3.3  || instantiate || tuple           || 0.19853064499329776 ||
 ||          || instantiate || namedtuple      || 0.8839332649949938  ||
 ||          || access      || tuple           || 0.2663196460052859  ||
 ||          || access      || namedtuple      || 1.1236915799963754  ||
 ||          ||             ||                 ||                     ||
 || CPy 3.4  || instantiate || tuple           || 0.2100249359937152  ||
 ||          || instantiate || namedtuple      || 0.707535210007336   ||
 ||          || access      || tuple           || 0.2940493019996211  ||
 ||          || access      || namedtuple      || 0.9200455860118382  ||
 ||          ||             ||                 ||                     ||
 || PyPy 2.3 || instantiate || tuple           || 0.00525689125061    ||
 ||          || instantiate || namedtuple      || 0.00653004646301    ||
 ||          || access      || tuple           || 0.00449419021606    ||
 ||          || access      || namedtuple      || 0.00840997695923    ||

 From this it seems that namedtuple indeed is noticeably more expensive
 than a plain tuple (except, unsurprisingly, on PyPy). However as the
 absolute times for namedtuple are still quite short even at one million
 iterations I think the impact on Django's URL resolvers should be
 negligible.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20757#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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.44d0313a55d2df438176d7cc2a634689%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to