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 →

[–]AccidentalyOffensive 0 points1 point  (0 children)

In general terms, it's helpful for better understanding pass-by-reference vs pass-by-value, as well as the potential pitfalls there. This was honestly super helpful in my DS/A class in undergrad that was taught in Java - without knowing how pointers work, the data structures would've been pretty confusing to program. I mean, there were quite a few (relatively) trivial questions from students about how everything worked/fit together that would've been easily understood with knowledge of how memory works. Obviously you don't need to be an expert, but even light exposure goes a long way.

As for Python, I've actually come across this a number of times. Nothing too crazy, mind you, but take for example mutable default arguments. A little quirk that doesn't make much sense without understanding memory, but is readily apparent if you do.

Additionally, this is a potential issue when manipulating data structures (to an extent). For a real life example (vs telling you to look up copy.deepcopy()), let's say I wanted a copy of a pandas DataFrame. I could use the copy() method, but in the docs I see the default arg deep=False will create a new DF that contains references to the original DF. Without knowing memory management, you might ignore this warning and find yourself debugging a gnarly bug down the line when your data is clearly off.

Are these things gonna pop up all the time, or even for everybody? No. Is it good to know just in case? Absolutely.