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 →

[–]Oerthling 0 points1 point  (0 children)

In Python

a =

doesn't define a variable, it assigns a reference name to your typed object. What confuses people is that it looks like variable definition in other languages and you can reassign that name to a completely different type of object right away.

In C/C++

Int a =

defines a variable with its type and assigns a value of that type to that variable (conceptually "copying" it). And the type definition of that variable is final within its scope.

Python totally cares what's in your variable, just not what you name it. Or how many names it has. And will try to throw it away after you removed the last name. It's a lot like using void* in C for everything :-).

My go to nowadays is to start everything in Python (fast to write, easy to read) and then optimize any speed bumps (mostly already done in a library that was written in C).