caching

Why does adding the decorator @lru_cache(from functools) break this function?

Why does adding the decorator @lru_cache(from functools) break this function? Question: The function is a part of the solution to the following problem: "Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through 9 are used. Each number is used at most …

Total answers: 3

Cache Django REST Framework HTTP Streaming Response?

Cache Django REST Framework HTTP Streaming Response? Question: I am trying to cache Django REST Framework HTTP streaming responses. My thinking is a Response sub-class can write the chunks into a temporary file as it streams, and on closing after streaming the final chunk, run a callable that copies the file into cache. from django.http …

Total answers: 1

Unable To Update Image On Google Cloud Storage via API

Unable To Update Image On Google Cloud Storage via API Question: I am trying to overwrite an image in my Cloud Storage over the Python API, but after I overwrite it and refresh (and delete browsercache) the Cloud Webpage or the public link the image is still the same, even the next day but sometimes …

Total answers: 1

How to cache StreamingResponse?

How to cache StreamingResponse? Question: Is that possible to cache StreamingResponse? I saw, a couple of tickets related to this topic (e.g. here), but none of them gave clear answer. I tried aiocache package and fastapi-cache package, but all this kind of packages try to convert value being cached to JSON or even a string, …

Total answers: 1

Python function with cache give me an error, but why?

Python function with cache give me an error, but why? Question: I have the task to write a program with a function, that takes 2 integer and returns the numbers between the 2 integers. Example calc_range(3,5) -> 3,4. The function should save the data in a cache, for the reason, that if I ask the …

Total answers: 1

Columns must be same length as ke by using lru_cache

Columns must be same length as ke by using lru_cache Question: I have a problem. I want to get the coordinates long and lat from the address. I want to check directly in the method whether this address already has a long and lat value and if so, should this be taken and not queried …

Total answers: 1

Does SQLite cache results even after commit/close?

Does SQLite cache results even after commit/close? Question: I wish to run some benchmarks on different databases that I have. I repeat every query n times so that I can report average query times. I am aware that SQLite caches statements, as per the documentation: The sqlite3 module internally uses a statement cache to avoid …

Total answers: 1

Python in-memory files for caching large files

Python in-memory files for caching large files Question: I am doing very large data processing (16GB) and I would like to try and speed up the operations through storing the entire file in RAM in order to deal with disk latency. I looked into the existing libraries but couldn’t find anything that would give me …

Total answers: 2

Create a decorator in Python, which remembers last output of the function

Create a decorator in Python, which remembers last output of the function Question: I need to create a decorator which remembers last call result of the function which it decorates. For example, I have a function: def summarize(*args): result = "" for i in args: result += i print(‘New result = ‘, result) return result …

Total answers: 2

How to cache a variable with Flask?

How to cache a variable with Flask? Question: I am building a web form using Flask and would like the user to be able to enter multiple entries, and give them the opportunity to regret an entry with an undo button, before sending the data to the database. I am trying to use Flask-Caching but …

Total answers: 3