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.

Author sobolevn
Recipients sobolevn
Date 2021-08-11.20:01:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1628712079.84.0.245411182001.issue44891@roundup.psfhosted.org>
In-reply-to
Content
While working on `RustPython` (original issue: https://github.com/RustPython/RustPython/issues/2840), I've noticed that `tuple` in CPython has explicit tests that `id` does not change when multiplied by `1`, related:
- https://github.com/python/cpython/blob/64a7812c170f5d46ef16a1517afddc7cd92c5240/Lib/test/seq_tests.py#L322
- https://github.com/python/cpython/blob/64a7812c170f5d46ef16a1517afddc7cd92c5240/Lib/test/seq_tests.py#L286-L287

But, I cannot find similar tests for `str` and `bytes` which also have the same behavior: 
- `str`: https://github.com/python/cpython/blob/64a7812c170f5d46ef16a1517afddc7cd92c5240/Objects/unicodeobject.c#L12709-L12710
- `bytes`: https://github.com/python/cpython/blob/64a7812c170f5d46ef16a1517afddc7cd92c5240/Objects/bytesobject.c#L1456-L1458

Code:

```python
>>> b = b'abc'
>>> id(b), id(b * 1), id(b) == id(b * 1)
(4491073360, 4491073360, True)

>>> s = 'abc'
>>> id(s), id(s * 1), id(s) == id(s * 1)
(4489513776, 4489513776, True)
```

If tests are indeed missing and should be added, I would love to contribute them.
History
Date User Action Args
2021-08-11 20:01:19sobolevnsetrecipients: + sobolevn
2021-08-11 20:01:19sobolevnsetmessageid: <1628712079.84.0.245411182001.issue44891@roundup.psfhosted.org>
2021-08-11 20:01:19sobolevnlinkissue44891 messages
2021-08-11 20:01:19sobolevncreate