memory-management

What does "domain" mean in Python's tracemalloc?

What does "domain" mean in Python's tracemalloc? Question: Python’s tracemalloc documentation defines "domain" as an "address space of a memory block" and identifies a domain using an integer. It also says: tracemalloc uses the domain 0 to trace memory allocations made by Python. C extensions can use other domains to trace other resources What are …

Total answers: 1

Why does Python's functools.partial definition use function attributes?

Why does Python's functools.partial definition use function attributes? Question: In the functools.partial example definition, function attributes are used in the returned partial function object: def partial(func, /, *args, **keywords): def newfunc(*fargs, **fkeywords): newkeywords = {**keywords, **fkeywords} return func(*args, *fargs, **newkeywords) newfunc.func = func newfunc.args = args newfunc.keywords = keywords return newfunc What would be the …

Total answers: 3

How to store data in seperate memory mdoules

How to store data in seperate memory mdoules Question: I’m working on an image processing pipeline in Python and I’m using Cython for the main computation so that it can run really fast. From early benchmarks, I found a memory bottleneck where the code would not scale at all using multiple threads. I revised the …

Total answers: 1

Why do python variables of same value point to the same memory address?

Why do python variables of same value point to the same memory address? Question: I ran into an interesting case today wherein a = 10 b = 10 print (a is b) logged out True. I did some searching and came across the concept of interning. Now that explains why True is correct for the …

Total answers: 1

free memory as I iterate over a list

free memory as I iterate over a list Question: I have a hypothetical question regarding the memory usage of lists in python. I have a long list my_list that consumes multiple gigabytes if it is loaded into memory. I want to loop over that list and use each element only once during the iteration, meaning …

Total answers: 1

How to pass arguments to another .py

How to pass arguments to another .py Question: I’m newbie with python programming and I’m facing an issue with Windows Memory, so I want to understand if the way I’m calling the other "subprogram" ic causing this problem. Basically I’ve done a main program from which I call the other .py (called second_py.py) like this: …

Total answers: 1

Is there a danger in letting a generator run for a very long time?

Is there a danger in letting a generator run for a very long time? Question: I am designing code to run certain enumeration simulations. I’ll put the code at the end, but I don’t think my question really should concern the details of this program. In principle I think my question could apply just as …

Total answers: 1

Rotate array (list) in linear time and constant memory

Rotate array (list) in linear time and constant memory Question: How can I be sure that this Python algorithm uses constant memory? A theoretical proof is OK. A textbook* has this exercise: write an algorithm to “rotate” a list of n integers, in other words to shift the list values by k indices each. The …

Total answers: 3

How do we approximately calculate how much memory is required to run a program?

How do we approximately calculate how much memory is required to run a program? Question: Today I was trying to implement an object detection API in Tensorflow. After carrying out the training process, I was trying to run the program to detect objects in webcam. As I was running it, the following message was printed …

Total answers: 3