Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
-
@halfflat People who program C++ shouldn't throw stones:
int array[10];
0[array] = 5;
;-)
I know, I don't remember the last time I used a legit array in C++, but meh. -
@Kimmax In the second question it explains that -5 to 256 are indeed objects when assigned to a variable. Not sure what happens when math is applied though.
-
I never even thought about trying to use the "is" operator with numbers. I also will never become a pentester.
-
Hazarth95304yIn python (and many other languages including java)
Often used values are pooled. For example numbers up to 256 are pooled in python.
That means that all numbers up to 256 will have a single place in memory
a = 256
a is 256 results in True
But a = 257
a is 257 will be False
The idea is to save time and space for values that appear commonly in code
This is normal behaviour and also why you should be using == instead of reference comparison (is)
Related Rants
Python.. I seriously thought we understood each other but I guess it's all over now.💔
random
python