Re: [Python-Dev] Is there any remaining reason why weakref callbacks shouldn't be able to access the referenced object?

2017-01-15 Thread Armin Rigo
Hi,

Sorry to reply in this old thread.  We just noticed this on #pypy:

On 22 October 2016 at 05:32, Nick Coghlan  wrote:
> The weakref-before-__del__ ordering change in
> https://www.python.org/dev/peps/pep-0442/#disposal-of-cyclic-isolates
> only applies to cyclic garbage collection,so for normal refcount
> driven object cleanup in CPython, the __del__ still happens first:
>
> >>> class C:
> ... def __del__(self):
> ... print("__del__ called")
> ...
> >>> c = C()
> >>> import weakref
> >>> def cb():
> ... print("weakref callback called")
> ...
> >>> weakref.finalize(c, cb)
> 
> >>> del c
> __del__ called
> weakref callback called

Nick, it seems you're suggesting that before PEP 442 (in CPython 3.4)
the __del__ happened before the weakref-clearing operation as well.
That's not the case: before CPython 3.4, weakrefs are always cleared
first.  The situation became more muddy in 3.4, where weakrefs are
usually cleared after the __del__ is called---in the absence of
reference cycles (so it's a backward-incompatible change).  If there
are reference cycles, then the weakref is cleared before the __del__
is called.

This can be shown in your example by replacing "weakref.finalize(c,
cb)" with an old-style "wr = weakref.ref(c, cb)".  Then CPython <= 3.3
and >= 3.4 print the two lines in opposite order.


A bientôt,

Armin.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] support of the Android platform

2017-01-15 Thread Xavier de Gaye

On 01/14/2017 09:56 PM, Victor Stinner wrote:
> Great job! Thank you and Chi Hsuan Yen!
>
> Did you get feedback from users? Maybe from the Kivy community?
>
> Victor
>
> Le 14 janv. 2017 18:31, "Xavier de Gaye" a écrit :
>
> Only a few minor issues are left to be fixed before the support of the
> Android platform may be considered. See the current status at msg285493 
[1]
> in the Android meta-issue 26865 [2].


Yes Chi Hsuan Yen is a great contributor to this project.

AFAIK Kivy uses the CrystaX NDK [1] for Python 3 instead of the
Android NDK, mainly because the Android NDK did not support wide
character until API level 21.

Xavier

[1] https://www.crystax.net/en

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com