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 serhiy.storchaka
Recipients mark.dickinson, serhiy.storchaka, tehybel, terry.reedy
Date 2016-08-28.04:35:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472358923.45.0.632589597127.issue27867@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2016-08-28 04:35:23serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, mark.dickinson, tehybel
2016-08-28 04:35:23serhiy.storchakasetmessageid: <1472358923.45.0.632589597127.issue27867@psf.upfronthosting.co.za>
2016-08-28 04:35:23serhiy.storchakalinkissue27867 messages
2016-08-28 04:35:22serhiy.storchakacreate