1
0
mirror of https://github.com/django/django.git synced 2025-01-18 22:33:44 +00:00
Ran Benita ee36e101e8 Optimized lazy() by removing use of @total_ordering.
@total_ordering is slow. Using the following micro-benchmark
(resultclasses intentionally omitted to narrow the scope):

    import cProfile
    from django.utils.functional import lazy
    def identity(x): return x
    cProfile.run("for i in range(10000): str(lazy(identity)(1))")

Before:

    380003 function calls in 0.304 seconds

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
         1    0.016    0.016    0.304    0.304 <string>:1(<module>)
     10000    0.002    0.000    0.002    0.000 bench.py:5(double)
     10000    0.005    0.000    0.006    0.000 functional.py:100(__cast)
     10000    0.007    0.000    0.013    0.000 functional.py:106(__str__)
     10000    0.005    0.000    0.017    0.000 functional.py:140(__wrapper__)
     10000    0.020    0.000    0.258    0.000 functional.py:60(lazy)
     10000    0.039    0.000    0.039    0.000 functional.py:68(__proxy__)
     10000    0.010    0.000    0.012    0.000 functional.py:77(__init__)
     10000    0.002    0.000    0.002    0.000 functional.py:84(__prepare_class__)
     10000    0.025    0.000    0.075    0.000 functools.py:186(total_ordering)
     10000    0.015    0.000    0.028    0.000 functools.py:189(<setcomp>)
     10000    0.024    0.000    0.044    0.000 functools.py:37(update_wrapper)
     10000    0.005    0.000    0.005    0.000 functools.py:67(wraps)
     10000    0.074    0.000    0.114    0.000 {built-in method builtins.__build_class__}
         1    0.000    0.000    0.304    0.304 {built-in method builtins.exec}
    150000    0.023    0.000    0.023    0.000 {built-in method builtins.getattr}
     10000    0.004    0.000    0.004    0.000 {built-in method builtins.max}
     80000    0.025    0.000    0.025    0.000 {built-in method builtins.setattr}
         1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
     10000    0.003    0.000    0.003    0.000 {method 'update' of 'dict' objects}

After:

    240003 function calls in 0.231 seconds

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
         1    0.016    0.016    0.231    0.231 <string>:1(<module>)
     10000    0.002    0.000    0.002    0.000 bench.py:5(double)
     10000    0.006    0.000    0.012    0.000 functional.py:105(__str__)
     10000    0.005    0.000    0.017    0.000 functional.py:159(__wrapper__)
     10000    0.015    0.000    0.186    0.000 functional.py:60(lazy)
     10000    0.022    0.000    0.022    0.000 functional.py:68(__proxy__)
     10000    0.010    0.000    0.012    0.000 functional.py:76(__init__)
     10000    0.002    0.000    0.002    0.000 functional.py:83(__prepare_class__)
     10000    0.004    0.000    0.006    0.000 functional.py:99(__cast)
     10000    0.023    0.000    0.043    0.000 functools.py:37(update_wrapper)
     10000    0.004    0.000    0.004    0.000 functools.py:67(wraps)
     10000    0.102    0.000    0.124    0.000 {built-in method builtins.__build_class__}
         1    0.000    0.000    0.231    0.231 {built-in method builtins.exec}
     70000    0.011    0.000    0.011    0.000 {built-in method builtins.getattr}
     50000    0.007    0.000    0.007    0.000 {built-in method builtins.setattr}
         1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
     10000    0.003    0.000    0.003    0.000 {method 'update' of 'dict' objects}
2023-06-08 09:17:50 +02:00

======
Django
======

Django is a high-level Python web framework that encourages rapid development
and clean, pragmatic design. Thanks for checking it out.

All documentation is in the "``docs``" directory and online at
https://docs.djangoproject.com/en/stable/. If you're just getting started,
here's how we recommend you read the docs:

* First, read ``docs/intro/install.txt`` for instructions on installing Django.

* Next, work through the tutorials in order (``docs/intro/tutorial01.txt``,
  ``docs/intro/tutorial02.txt``, etc.).

* If you want to set up an actual deployment server, read
  ``docs/howto/deployment/index.txt`` for instructions.

* You'll probably want to read through the topical guides (in ``docs/topics``)
  next; from there you can jump to the HOWTOs (in ``docs/howto``) for specific
  problems, and check out the reference (``docs/ref``) for gory details.

* See ``docs/README`` for instructions on building an HTML version of the docs.

Docs are updated rigorously. If you find any problems in the docs, or think
they should be clarified in any way, please take 30 seconds to fill out a
ticket here: https://code.djangoproject.com/newticket

To get more help:

* Join the ``#django`` channel on ``irc.libera.chat``. Lots of helpful people
  hang out there. See https://web.libera.chat if you're new to IRC.

* Join the django-users mailing list, or read the archives, at
  https://groups.google.com/group/django-users.

To contribute to Django:

* Check out https://docs.djangoproject.com/en/dev/internals/contributing/ for
  information about getting involved.

To run Django's test suite:

* Follow the instructions in the "Unit tests" section of
  ``docs/internals/contributing/writing-code/unit-tests.txt``, published online at
  https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests

Supporting the Development of Django
====================================

Django's development depends on your contributions. 

If you depend on Django, remember to support the Django Software Foundation: https://www.djangoproject.com/fundraising/
Description