4 ms·
Several times in Python I've used the built-in CTypes library to cut down the memory footprint by using giant Arrays of (literally C) Structs.
by corysama 7y ago
Several times in Python I've used the built-in CTypes library to cut down the memory footprint by using giant Arrays of (literally C) Structs.
- danudey 7y agoI was bored and had time on my hands, so I played around a bit with some of the suggestions in this thread, but it seems as though a naive ctypes approach is the worst possible approach in the two cases I tested (arrays of integers, arrays of x,y struct). Here are my code and results: https://gist.github.com/danudey/94b5442b617a734a2366e824be159beb https://gist.github.com/danudey/94b5442b617a734a2366e824be15... Is there an approach that you use that produces better results than this? Because my naive approach is unmanageably worse for both performance (not recorded) and impact on Python's memory usage.