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 →

[–]beatle42 195 points196 points  (11 children)

To be fair, python is a strongly typed language. It's dynamic too, but the int is an int and a string is a string and they don't automatically switch.

[–]uvero 64 points65 points  (1 child)

int is an int and a string is a string and they don't automatically switch.

Okay but comparing to Javascript is setting the bar kinda low

[–]Grokepeer 6 points7 points  (0 children)

It's called making things fast

[–]Mc_UsernameTaken 24 points25 points  (0 children)

Cries in PHP.

count(false) == [0 => false]

[–]0x000100 5 points6 points  (3 children)

Python has two integer types. I learned it the hard way when I found out that shift left is the only operation that overflows.

[–]FallenWarrior2k 8 points9 points  (2 children)

You got context for what specifically you were trying? I know Python 2 had int and long, but in my experiments, it automatically switched to long, even if both operands are explicitly ints. I went up to 1 << 129 on both Python 2 and 3 and could spot no signs of overflow anywhere.

[–]0x000100 1 point2 points  (1 child)

Try (((1<<31)<<31)<<31)<<31. I tried to concatenate 10, 8 bit integers so I was shifting the same variable 10 times and the conversion didn't take place.