Message399414
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. |
|
Date |
User |
Action |
Args |
2021-08-11 20:01:19 | sobolevn | set | recipients:
+ sobolevn |
2021-08-11 20:01:19 | sobolevn | set | messageid: <1628712079.84.0.245411182001.issue44891@roundup.psfhosted.org> |
2021-08-11 20:01:19 | sobolevn | link | issue44891 messages |
2021-08-11 20:01:19 | sobolevn | create | |
|