Go to file
Nick Pope ebec6f429f Fixed #33865 -- Optimized LimitedStream wrapper.
The current implementation of `LimitedStream` is slow because `.read()`
performs an extra copy into a buffer and `.readline()` performs two
extra copies. We're already typically wrapping a `BytesIO` object so
this is unnecessary.

This implementation has largely been untouched for 12 years and,
inspired by a simpler implementation in `werkzeug`, I was able to
achieve the following performance improvement:

```
LimitedStream.read() (single line): Mean +- std dev: [bench_limitedstream-main] 286 ns +- 6 ns -> [bench_limitedstream-patch] 227 ns +- 6 ns: 1.26x faster
LimitedStream.readline() (single line): Mean +- std dev: [bench_limitedstream-main] 507 ns +- 11 ns -> [bench_limitedstream-patch] 232 ns +- 8 ns: 2.18x faster
LimitedStream.read(8192) (single line): Mean +- std dev: [bench_limitedstream-main] 360 ns +- 8 ns -> [bench_limitedstream-patch] 297 ns +- 6 ns: 1.21x faster
LimitedStream.readline(8192) (single line): Mean +- std dev: [bench_limitedstream-main] 602 ns +- 10 ns -> [bench_limitedstream-patch] 305 ns +- 10 ns: 1.98x faster
LimitedStream.read() (multiple lines): Mean +- std dev: [bench_limitedstream-main] 290 ns +- 5 ns -> [bench_limitedstream-patch] 236 ns +- 6 ns: 1.23x faster
LimitedStream.readline() (multiple lines): Mean +- std dev: [bench_limitedstream-main] 517 ns +- 19 ns -> [bench_limitedstream-patch] 239 ns +- 7 ns: 2.16x faster
LimitedStream.read(8192) (multiple lines): Mean +- std dev: [bench_limitedstream-main] 363 ns +- 8 ns -> [bench_limitedstream-patch] 311 ns +- 11 ns: 1.17x faster
LimitedStream.readline(8192) (multiple lines): Mean +- std dev: [bench_limitedstream-main] 601 ns +- 12 ns -> [bench_limitedstream-patch] 308 ns +- 7 ns: 1.95x faster

Geometric mean: 1.59x faster
```
2022-07-24 01:30:21 +01:00
.github Bumped versions in Github actions configuration. 2022-06-24 07:38:13 +02:00
.tx Removed contrib-messages entry in Transifex config file 2016-06-29 21:11:30 +02:00
django Fixed #33865 -- Optimized LimitedStream wrapper. 2022-07-24 01:30:21 +01:00
docs Refs #25756 -- Doc'd inability to use file fields with PostgreSQL ArrayField. 2022-07-23 16:12:01 +02:00
extras Refs #23433 -- Removed django-admin.py entry point per deprecation timeline. 2021-01-14 17:50:04 +01:00
js_tests Fixed #33637 -- Improved initial zoom level in MapWidget. 2022-04-14 11:50:31 +02:00
scripts Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
tests Fixed #33865 -- Optimized LimitedStream wrapper. 2022-07-24 01:30:21 +01:00
.editorconfig Refs #33476 -- Adjusted docs and config files for Black. 2022-02-07 20:36:04 +01:00
.eslintignore Refs #32165 -- Bumped minimum ESLint version to 7.16.0 to match pre-commit configuration. 2021-01-19 21:11:34 +01:00
.eslintrc Enabled ESLint's "eqeqeq" rule. 2020-05-18 07:42:51 +02:00
.git-blame-ignore-revs Refs #33476 -- Ignored formatting changes in git blame. 2022-02-08 07:14:51 +01:00
.gitattributes Fixed #19670 -- Applied CachedFilesMixin patterns to specific extensions 2016-03-30 14:34:41 +02:00
.gitignore Fixed #22446 -- Added tox.ini to automate pull request checks. 2016-07-20 14:06:28 -04:00
.pre-commit-config.yaml Bumped versions in pre-commit and npm configurations. 2022-06-28 08:53:05 +02:00
.readthedocs.yml Configured Read The Docs to build all formats. 2021-11-18 12:21:00 +01:00
AUTHORS Corrected various typos in contributing docs. 2022-06-30 11:09:06 +02:00
CONTRIBUTING.rst Added link to the code of conduct from contributing guides. 2015-04-17 18:12:41 -04:00
Gruntfile.js Refs #31265 -- Updated .eslintignore to match eslint tests 2020-12-23 11:14:48 +01:00
INSTALL Fixed #32355 -- Dropped support for Python 3.6 and 3.7 2021-02-10 10:20:54 +01:00
LICENSE Whitespace cleanup. 2013-10-10 16:49:20 -04:00
LICENSE.python Updated Python license for 2022. 2022-01-12 11:21:51 +01:00
MANIFEST.in Fixed #31524 -- Removed minified static assets from the admin. 2020-05-14 16:07:56 +02:00
README.rst Fixed 32956 -- Lowercased spelling of "web" and "web framework" where appropriate. 2021-07-29 06:24:12 +02:00
package.json Bumped versions in pre-commit and npm configurations. 2022-06-28 08:53:05 +02:00
pyproject.toml Refs #33476 -- Used black's force-exclude instead of extend-exclude. 2022-03-09 14:51:13 +01:00
setup.cfg Updated asgiref dependency for 4.1 release series. 2022-06-16 12:13:15 +02:00
setup.py Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
tox.ini Refs #33476 -- Adjusted docs and config files for Black. 2022-02-07 20:36:04 +01:00

README.rst

======
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/