Henrique Andrade <h...@unscrambl.com> added the comment: You're a missing the fact that in C++, there is no garbage collector. The destructor both releases resources and deallocates memory.
There is no window between releasing resources and object destruction. Python, while not exactly like Java, is similar to Java in the sense that there is a window of time between an object no longer having a reference and its being reaped by the garbage collector. During that window, resources can be held even if no longer in use. In extreme cases, a lot of these resources can be held (think hundreds of Queues being created and closed in succession without an intervening GC run), even if not used. Sure, at some point, they will be reaped, but it might be a while. And that's one of the reasons Python and Java have mechanisms to acquire/release resources in a more timely fashion. Context managers in the former and try-with-resources in the latter. The mere presence of a proper close/shutdown method can make this work in an improved way in the case of a Queue, allowing OS resources (pipes) to be released in a more timely fashion. But, sure, let's hear what the community thinks. On Sun, Mar 18, 2018, 14:01 Pablo Galindo Salgado <rep...@bugs.python.org> wrote: > > Pablo Galindo Salgado <pablog...@gmail.com> added the comment: > > > RAII in C++ ensures that, on object destruction, resources that have > been acquired will be closed and deallocated. > > Which is exactly what is happening here. When the queue gets destroyed > (because the reference count reaches 0 or because of the garbage collector) > resources that have been acquired by the queue will be closed an > deallocated. > > Sadly, I don't think I have anything different to apport to this > discussion, so let's see what other people opinions are on this. > > Of course, feel free to start a thread on python-dev or python-ideas on > how to improve the design. :) > > ---------- > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue33081> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33081> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com