[pypy-dev] FAQ entry

Yuriy Taraday yorik.sar at gmail.com
Wed Apr 8 11:43:16 CEST 2015


On Wed, Apr 8, 2015 at 12:02 PM Armin Rigo <arigo at tunes.org> wrote:

> Hi Yuriy,
>
> On 8 April 2015 at 10:47, Yuriy Taraday <yorik.sar at gmail.com> wrote:
> > will end up executing them. So my argument is: why not make it clear that
> > __del__ will run in a separate thread instead of trying to pretend that
> it's
> > something more predictable than that?
>
> For example, because it would break this class (it's left as an
> exercise to the reader to understand why):
>
> class Foo(object):
>     num_instances = 0
>
>     def __init__(self):
>         Foo.num_instances += 1
>
>     def __del__(self):
>         Foo.num_instances -= 1
>

It's already broken if it's used in multithreaded app. For single-threaded
apps we can make an exception and keep things running as they are now, i.e.
keep it single-threaded. This will also prevent unnecessary multithreading
initialization.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150408/0d7e2711/attachment.html>


More information about the pypy-dev mailing list