Name a Django cache backend.
Simple meaning
LocMemCache is an in-process dict, useful for development only.
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready Python & Django questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
LocMemCache is an in-process dict, useful for development only.
Open the full page for Why, Steps, Example and Key takeaway.
Celery is a distributed task queue.
Open the full page for Why, Steps, Example and Key takeaway.
A request thread should return quickly
Open the full page for Why, Steps, Example and Key takeaway.
itertools is a standard-library toolkit of fast, memory-efficient iterators.
Open the full page for Why, Steps, Example and Key takeaway.
count(start=0, step=1) yields an infinite arithmetic sequence.
Open the full page for Why, Steps, Example and Key takeaway.
asyncio is Python's built-in library for cooperative concurrent I/O using the event loop.
Open the full page for Why, Steps, Example and Key takeaway.
async def defines a coroutine function.
Open the full page for Why, Steps, Example and Key takeaway.
copy.copy duplicates the outer container but shares nested objects.
Open the full page for Why, Steps, Example and Key takeaway.
sys.getsizeof returns the size of the object itself, not nested containers.
Open the full page for Why, Steps, Example and Key takeaway.
The GIL is a mutex in CPython that allows only one thread to execute Python bytecode at a time.
Open the full page for Why, Steps, Example and Key takeaway.
Dicts locate entries by hash then equality, so a key must implement a stable __hash__ and __eq__.
Open the full page for Why, Steps, Example and Key takeaway.
A dict is flexible but typo-prone and has no field documentation.
Open the full page for Why, Steps, Example and Key takeaway.
CPython ints are arbitrary-precision
Open the full page for Why, Steps, Example and Key takeaway.
The default object is created once, at function definition, and shared across calls.
Open the full page for Why, Steps, Example and Key takeaway.
CPU-bound threads compete for the GIL, so they rarely use more than one core for Python bytecode.
Open the full page for Why, Steps, Example and Key takeaway.
Threads help when they spend time in I/O or in C code that releases the GIL, such as reading sockets, waiting on a database driver, or compressing in zlib.
Open the full page for Why, Steps, Example and Key takeaway.
threading shares one process and one GIL, so CPU-bound Python does not parallelize.
Open the full page for Why, Steps, Example and Key takeaway.
Open the full page for Why, Steps, Example and Key takeaway.
Use a nested factory: the outer function takes decorator arguments and returns the real decorator, which returns the wrapper.
Open the full page for Why, Steps, Example and Key takeaway.
If a class implements __init__ to receive the function and __call__ to run the wrapper, instances are callable decorators.
Open the full page for Why, Steps, Example and Key takeaway.