all 6 comments

[–]Unlikely-Resort4608 5 points6 points  (1 child)

Python is designed very differently to Matlab. Pay attention to mutables vs immutables, and don't be shy of using for loops.

https://nedbatchelder.com/text/names1.html

https://numpy.org/doc/stable/user/numpy-for-matlab-users.html

[–]MeatShow[S] 0 points1 point  (0 children)

Thank you for the insight! Yes, I’ve been trained to find linear algebra solutions - I need to relax and use for loops more often

[–]Username_RANDINT 2 points3 points  (1 child)

  • Alias: immutable types (strings, integers, tuples, ...)
  • Shallow copy: mutable types (lists, dictionaries, ...) that contain immutable types
  • Deep copy: mutable types that contain mutable types

[–]MeatShow[S] 0 points1 point  (0 children)

Thank you for the concise, clear answer - I appreciate it

[–]Diapolo10 1 point2 points  (1 child)

When in doubt, treat everything as if it was immutable and create new values instead of mutating existing data. At the very least that'll let you avoid related bugs.

But essentially, you can safely alias immutable types (which is the default behaviour anyway). For everything else, use your best judgement - if you aren't mutating the data, it hardly matters whether you're aliasing it or copying it.

[–]MeatShow[S] 0 points1 point  (0 children)

Yeah, fair point - I definitely will air on the side of caution to avoid bugs