Remember I told you about numbers from -5 to 255 interned. That is, the numbers are preliminary placed and cached in memory. So, there is more to it.
You can access this memory if you want and change value. Say, change literal 4 to value 5. I'll probably be damned by many people for this post, but here is a sample code:
P.S. Try to replace 0 with 1
#python
You can access this memory if you want and change value. Say, change literal 4 to value 5. I'll probably be damned by many people for this post, but here is a sample code:
>>> import ctypes
>>> ctypes.memmove(id(4) + 24, id(5) + 24, 8)
>>> print(2 * 2) # 5
Have fun debugging!P.S. Try to replace 0 with 1
#python
Telegram
L̶u̵m̶i̵n̷o̴u̶s̶m̶e̵n̵B̶l̵o̵g̵
Perhaps not every Python developer knows the interesting property of the CPython that makes newcomers go crazy:
>>> a = 255
>>> b = 255
>>> a == b
True
>>> a is b
True
The double equal operator checks that the objects values are equal and the is operator…
>>> a = 255
>>> b = 255
>>> a == b
True
>>> a is b
True
The double equal operator checks that the objects values are equal and the is operator…
The article on PythonSpeed compares three Python code analysis tools: Pylint, Flake8, and Ruff. Pylint is powerful but slow and complex, Flake8 is faster and simpler but less rigorous, and Ruff is a new tool that offers high speed with solid functionality, though it’s still maturing. The author suggests Ruff for new projects due to its balance of speed and features but acknowledges Pylint and Flake8 might be better suited for existing codebases.
🔗Link: https://pythonspeed.com/articles/pylint-flake8-ruff/
#article #python
🔗Link: https://pythonspeed.com/articles/pylint-flake8-ruff/
#article #python
Python⇒Speed
Goodbye to Flake8 and PyLint: faster linting with Ruff
Ruff is a new linter that is vastly faster than PyLint and flake8—with many of the same checks.
💯4