On Mon, Mar 6, 2017 at 3:28 PM, Elliot Gorokhovsky <elliot.gorokhov...@gmail.com> wrote: > On Sun, Mar 5, 2017 at 11:21 PM Jelle Zijlstra <jelle.zijls...@gmail.com> > wrote: >> >> >> I think using a global is unsafe even without multithreading, because >> the compare function itself could end up doing list.sort() (it's >> calling arbitrary Python code after all). > > > Right, of course. So, clearly, the only safe solution is to just keep > everything in local scope and pass the compare function pointer into every > function that calls ISLT or IFLT. Too bad. I'll rewrite the patch to > implement this and open a new issue on the bug tracker (and close my current > issue).
I think there is another safe solution: Gave up unsafe_object_compare. Compare function of long, float, and unicode must not call list.sort(), and must not release GIL. So all you need is, backup old compare_function before sort, and restore it after sort. _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/