This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: is comparison returns False while ids are the same.
Type: behavior Stage: resolved
Components: Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, ihalil95, terry.reedy
Priority: normal Keywords:

Created on 2020-05-08 16:06 by ihalil95, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit
2020-05-07_16-47-56-afa654f51735fad98b3a593a2ea539fd.png ihalil95, 2020-05-08 16:06 Code error
Pull Requests
URL Status Linked Edit
PR 20004 ihalil95, 2020-05-08 16:06
Messages (3)
msg368450 - (view) Author: halil ibrahim yıldırım (ihalil95) Date: 2020-05-08 16:06
While id(a[:]) and id(a[0:3]) are the same however is comparison returns False. I thought it could be a bug.

>>> a = [1, 2, 3]
>>> id(a[:]) == id(a[0:3])
>>> a[:] is a[0:3]
msg368451 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-05-08 16:21
This isn't doing what you think. Because you throw away the object after computing its id, the same memory is reused and you get the same id.  Consider:

>>> a = [1,2,3]
>>> b = [3,4,5]
>>> id(a[:]) == id(b[:])

There's no problem here, but it does show that you need to be careful with "is" and "id".
msg368457 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-08 19:31
python-list mailing list,, is one good place to ask "Is this a bug?"
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84745
2020-05-08 19:31:34terry.reedysetnosy: + terry.reedy
messages: + msg368457
2020-05-08 16:21:11eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg368451

resolution: not a bug
stage: resolved
2020-05-08 16:06:59ihalil95create