python-horror-show icon indicating copy to clipboard operation
python-horror-show copied to clipboard

More about hidden memory

Open noviluni opened this issue 7 years ago • 2 comments

That's not a issue with the project but a question for you about a snippet that could be in the README.

I know another case which I think is related with your "hidden memory" snippet, but I can't understand why it happens.

>>> x = 'a'*20
>>> y = 'a'*20
>>> x is y
True

>>> x = 'a'*21
>>> y = 'a'*21
>>> x is y
False

And then, if we create directly a string with more than 20 equals characters:

>>> x = 'aaaaaaaaaaaaaaaaaaaaaaaaa'
>>> y = 'aaaaaaaaaaaaaaaaaaaaaaaaa'
>>> x is y
True

It seems that they are identical.

Do you know why it happens?

Thanks in advance!

noviluni avatar Jan 25 '19 09:01 noviluni

@noviluni I hope this answer and comment from SO will answer your question.

abdulniyaspm avatar Sep 22 '20 02:09 abdulniyaspm

hey, yeah, really interesting, thanks @abdulniyaspm!

noviluni avatar Sep 23 '20 10:09 noviluni