New submission from Nikita Sobolev <m...@sobolevn.me>:
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. ---------- components: Tests messages: 399414 nosy: sobolevn priority: normal severity: normal status: open title: Tests for `id(a) == id(a * 1)` for `bytes` and `str` type: enhancement _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44891> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com