Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"tokenize.py comes out on top, which can make some sense as I am doing a lot of number formatting. "</p> <p>Makes no sense at all.</p> <p>See <a href="http://docs.python.org/library/tokenize.html" rel="nofollow noreferrer">http://docs.python.org/library/tokenize.html</a>.</p> <blockquote> <p>The tokenize module provides a lexical scanner for Python source code, implemented in Python</p> </blockquote> <p>Tokenize coming out on top means that you have dynamic code parsing going on.</p> <p>AFAIK (doing a search on the Django repository) Django does not use tokenize. So that leaves your program doing some kind of dynamic code instantiation. Or, you're only profiling the <strong>first</strong> time your program is loaded, parsed and run, leading to false assumptions about where the time is going.</p> <p>You should <strong>not</strong> ever do calculation in template tags -- it's slow. It involves a complex meta-evaluation of the template tag. You should do all calculations in the view in simple, low-overhead Python. Use the templates for presentation only.</p> <p>Also, if you're constantly doing queries, filters, sums, and what-not, you have a data warehouse. Get a book on data warehouse design, and follow the data warehouse design patterns.</p> <p>You must have a central fact table, surrounded by dimension tables. This is very, very efficient. </p> <p>Sums, group bys, etc., are can be done as <code>defaultdict</code> operations in Python. Bulk fetch all the rows, building the dictionary with the desired results. If this is too slow, then you have to use data warehousing techniques of saving persistent sums and groups separate from your fine-grained facts. Often this involves stepping outside the Django ORM and using RDBMS features like views or tables of derived data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload