How to query as GROUP BY in django?

If you mean to do aggregation you can use the aggregation features of the ORM: This results in a query similar to and the output would be of the form If you don’t include the order_by(), you may get incorrect results if the default sorting is not what you expect. If you want to include … Read more

How is Python’s List Implemented?

It’s a dynamic array. Practical proof: Indexing takes (of course with extremely small differences (0.0013 µsecs!)) the same time regardless of index: I would be astounded if IronPython or Jython used linked lists – they would ruin the performance of many many widely-used libraries built on the assumption that lists are dynamic arrays

UnicodeDecodeError, invalid continuation byte

In binary, 0xE9 looks like 1110 1001. If you read about UTF-8 on Wikipedia, you’ll see that such a byte must be followed by two of the form 10xx xxxx. So, for example: But that’s just the mechanical cause of the exception. In this case, you have a string that is almost certainly encoded in … Read more

Releasing memory in Python

Memory allocated on the heap can be subject to high-water marks. This is complicated by Python’s internal optimizations for allocating small objects (PyObject_Malloc) in 4 KiB pools, classed for allocation sizes at multiples of 8 bytes — up to 256 bytes (512 bytes in 3.3). The pools themselves are in 256 KiB arenas, so if … Read more