Mar-08-2021, 08:24 PM
(Mar-08-2021, 06:37 PM)snippsat Wrote:(Mar-08-2021, 03:48 PM)pprod Wrote: I understand Python saves variables in memory, right? As it does so, does it create any logs or files with a reference to the content of the variables?>>> n = 99 >>> id(n) 1966484706736 >>> help(id) Help on built-in function id in module builtins: id(obj, /) Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (CPython uses the object's memory address.) >>> globals()['n'] 99Variable is stored somewhere in the free memory that's available.
Also stored in global namespace,which is a internal dictionary(globales()
) that python use.
>>> a = 'hello world' >>> b = 'hello world' >>> a is b False >>> a == b Trueis
will return True if two variables point to the same object in memory.
==
if the objects referred by the variables are equal.
>>> a = 'hello world' >>> b = a >>> a is b True >>> a == b TrueOther languages havevariables
Python hasnames
.
So over here isa
andb
name tagged to same memory address.
Thanks for the insight, snippsat!