Python experiences, or: Why I like C++ more ;-)
So I’ve been coding some Python lately, because this is the language of choice for the “Computational Physics” course I’m attending. As the name says, it is more about physical and numerical problems than about programming, and the instructors chose Python as it’s easy to get into (most Physics students had not coded up to now).
I was quite excited about that, as I have wanted to learn Python for about a year. In the course of the course (pun intended), the only problem that many people ran into was copy-by-reference. When you’re working on some numerical problem, you’re dealing with number arrays most of the time (we were instructed to use NumPy, together with matplotlib for graphical output). And those are, unlike simple numbers, copied by reference. If you say “b = a”, where a is an array, and then modify the contents of b, you’ll also modify a, as b is just another name for a. The solution is “b = 1 * a”. The multiplication operation causes a deep copy of a to be created.
Recent comments
29 min 21 sec ago
2 hours 48 min ago
19 hours 54 min ago
20 hours 46 min ago
21 hours 18 min ago
1 day 6 hours ago
1 day 18 hours ago
1 day 21 hours ago
1 day 22 hours ago
1 day 22 hours ago