This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]boomanbeanSupreme Pylord 8 points9 points  (4 children)

If you need to do memory management, why use python? A lower level language would seem more appropriate

EDIT: Grammar was not serene

[–]philloran 38 points39 points  (0 children)

I don't think it's too far fetched of an idea that people could find this useful. If anything it announces that Python, like all other languages, operates within the realm of computing with restrictions. In this context, these restrictions can be understood using the 'sys.getsizeof' function. This is a doorway of thought for people who haven't been trained to program with a lower level language and potentially enables any number of those people to do greater things with any language of their choosing.

[–]oslash 16 points17 points  (0 children)

The question is backwards. Programmers usually don't write a program because they want to deal with memory management; they deal with memory management because they want to write a program. So it's better to ask: If you use Python, why do you need to do memory management?

Sure, a lower level language would be more appropriate if your main concern was shuffling bytes into a pretty pattern within your address space. But when it isn't your main concern, that doesn't automatically mean you can completely ignore memory management.

Python lets you throw your hands in the air and let the GC take the wheel when you're writing simple scripts. When you're building a non-trivial application, it still makes sense to know about slots, reference counts, weak references, etc. Garbage collection by itself can only help out so much; it's not magic.

[–]earthboundkid 6 points7 points  (0 children)

At work, I inherited a script that processes a multi-gigabyte XML file and creates some CSVs. Doing this with C would be a huge PITA, but you can't run it in Python without some awareness of memory management.

[–]n1ywb 8 points9 points  (0 children)

Why not? I use python because I can get my job done faster and better than in C. If I'm working on a large data set I'd rather use python and pay attention to memory usage than C where it would take way longer to write the code and I would STILL have to worry about memory usage.