Message273806
This is a toy example that exposes the problem, but the problem itself is not a toy problem. The key point is that calculating slice indices cause executing Python code and releases GIL. In multithread program a sequence can be changed not in toy __index__ method, but in other thread, in legitimate code. This is very hardly reproducible bug.
Variants B are not efficient. To determine the size of a sequence we should call its __len__() method. This is less efficient than using macros Py_SIZE() or PyUnicode_GET_LENGTH(). And it is not always possible to pass a sequence. In multidimensional array there is no such sequence (see for example _testbuffer.ndarray). |
|
Date |
User |
Action |
Args |
2016-08-28 04:35:23 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, terry.reedy, mark.dickinson, tehybel |
2016-08-28 04:35:23 | serhiy.storchaka | set | messageid: <1472358923.45.0.632589597127.issue27867@psf.upfronthosting.co.za> |
2016-08-28 04:35:23 | serhiy.storchaka | link | issue27867 messages |
2016-08-28 04:35:22 | serhiy.storchaka | create | |
|