Re: [Python-Dev] Bilingual scripts

2013-05-25 Thread Chris McDonough
On Fri, 2013-05-24 at 15:56 -0400, Barry Warsaw wrote: Here's something that seems to come up from time to time in Debian. Take a Python application like tox, nose, or pyflakes. Their executables work with both Python 2 and 3, but require a #! line to choose which interpreter to invoke.

Re: [Python-Dev] Bilingual scripts

2013-05-25 Thread Antoine Pitrou
On Fri, 24 May 2013 15:56:29 -0400 Barry Warsaw ba...@python.org wrote: Here's something that seems to come up from time to time in Debian. Take a Python application like tox, nose, or pyflakes. Their executables work with both Python 2 and 3, but require a #! line to choose which

Re: [Python-Dev] Bilingual scripts

2013-05-25 Thread Nick Coghlan
On Sat, May 25, 2013 at 5:56 AM, Barry Warsaw ba...@python.org wrote: Have any other *nix distros addressed this, and if so, how do you solve it? I believe Fedora follows the lead set by our own makefile and just appends a 3 to the script name when there is also a Python 2 equivalent (thus

Re: [Python-Dev] Bilingual scripts

2013-05-25 Thread Chris McDonough
On Sat, 2013-05-25 at 17:57 +1000, Nick Coghlan wrote: I think the simplest thing to do is just append the 3 to the binary name (as we do ourselves for pydoc) and then abide by the recommendations in PEP 394 to reference the correct system executable. I'm curious if folks have other concrete

Re: [Python-Dev] Bilingual scripts

2013-05-25 Thread Nick Coghlan
On Sat, May 25, 2013 at 8:17 PM, Chris McDonough chr...@plope.com wrote: On Sat, 2013-05-25 at 17:57 +1000, Nick Coghlan wrote: I think the simplest thing to do is just append the 3 to the binary name (as we do ourselves for pydoc) and then abide by the recommendations in PEP 394 to reference

[Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Łukasz Langa
Hello, Since the initial version, several minor changes have been made to the PEP. The history is visible on hg.python.org. The most important change in this version is that I introduced ABC support and completed a reference implementation. No open issues remain from my point of view. PEP: 443

[Python-Dev] __subclasses__() return order

2013-05-25 Thread Antoine Pitrou
Hello, In http://bugs.python.org/issue17936, I proposed making tp_subclasses (the internal container implementing object.__subclasses__) a dict. This would make the return order of __subclasses__ completely undefined, while it is right now slightly predictable. I have never seen __subclasses__

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Eli Bendersky
On Sat, May 25, 2013 at 6:18 AM, Antoine Pitrou solip...@pitrou.net wrote: Hello, In http://bugs.python.org/issue17936, I proposed making tp_subclasses (the internal container implementing object.__subclasses__) a dict. This would make the return order of __subclasses__ completely

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Antoine Pitrou
On Sat, 25 May 2013 06:23:56 -0700 Eli Bendersky eli...@gmail.com wrote: On Sat, May 25, 2013 at 6:18 AM, Antoine Pitrou solip...@pitrou.net wrote: Hello, In http://bugs.python.org/issue17936, I proposed making tp_subclasses (the internal container implementing object.__subclasses__)

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Antoine Pitrou
On Sat, 25 May 2013 15:26:58 +0200 Antoine Pitrou solip...@pitrou.net wrote: On Sat, 25 May 2013 06:23:56 -0700 Eli Bendersky eli...@gmail.com wrote: On Sat, May 25, 2013 at 6:18 AM, Antoine Pitrou solip...@pitrou.net wrote: Hello, In http://bugs.python.org/issue17936, I

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Łukasz Langa
On 25 maj 2013, at 15:45, Antoine Pitrou solip...@pitrou.net wrote: On Sat, 25 May 2013 15:26:58 +0200 Antoine Pitrou solip...@pitrou.net wrote: On Sat, 25 May 2013 06:23:56 -0700 Eli Bendersky eli...@gmail.com wrote: On Sat, May 25, 2013 at 6:18 AM, Antoine Pitrou solip...@pitrou.net

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread PJ Eby
On Sat, May 25, 2013 at 8:08 AM, Łukasz Langa luk...@langa.pl wrote: The most important change in this version is that I introduced ABC support and completed a reference implementation. Excellent! A couple of thoughts on the implementation... While the dispatch() method allows you to look up

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Łukasz Langa
On 25 maj 2013, at 16:08, PJ Eby p...@telecommunity.com wrote: ISTM there should be some way to get at the raw registration info, perhaps by exposing a dictproxy for the registry. Is that really useful? Just today Antoine asked about changing behaviour of __subclasses__(), suspecting it isn't

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Nick Coghlan
On Sun, May 26, 2013 at 12:08 AM, PJ Eby p...@telecommunity.com wrote: On Sat, May 25, 2013 at 8:08 AM, Łukasz Langa luk...@langa.pl wrote: The most important change in this version is that I introduced ABC support and completed a reference implementation. Excellent! A couple of thoughts on

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Łukasz Langa
On 25 maj 2013, at 16:59, Nick Coghlan ncogh...@gmail.com wrote: I think I added an issue on the tracker for that somewhere... yup: http://bugs.python.org/issue16832 Given the global nature of the cache invalidation, it may be better as a module level abc.get_cache_token() function. I

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Nick Coghlan
On Sun, May 26, 2013 at 12:53 AM, Łukasz Langa luk...@langa.pl wrote: On 25 maj 2013, at 16:08, PJ Eby p...@telecommunity.com wrote: ISTM there should be some way to get at the raw registration info, perhaps by exposing a dictproxy for the registry. Is that really useful? Just today Antoine

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Nick Coghlan
On Sun, May 26, 2013 at 1:09 AM, Łukasz Langa luk...@langa.pl wrote: On 25 maj 2013, at 16:59, Nick Coghlan ncogh...@gmail.com wrote: I think I added an issue on the tracker for that somewhere... yup: http://bugs.python.org/issue16832 Given the global nature of the cache invalidation, it may

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread PJ Eby
On Sat, May 25, 2013 at 10:59 AM, Nick Coghlan ncogh...@gmail.com wrote: Given the global nature of the cache invalidation, it may be better as a module level abc.get_cache_token() function. Well, since the only reason to ever use it is to improve performance, it'd be better to expose it as an

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread PJ Eby
On Sat, May 25, 2013 at 9:18 AM, Antoine Pitrou solip...@pitrou.net wrote: In http://bugs.python.org/issue17936, I proposed making tp_subclasses (the internal container implementing object.__subclasses__) a dict. This would make the return order of __subclasses__ completely undefined, while it

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Nick Coghlan
On Sun, May 26, 2013 at 2:48 AM, PJ Eby p...@telecommunity.com wrote: On Sat, May 25, 2013 at 10:59 AM, Nick Coghlan ncogh...@gmail.com wrote: Given the global nature of the cache invalidation, it may be better as a module level abc.get_cache_token() function. Well, since the only reason to

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Łukasz Langa
On 25 maj 2013, at 17:13, Nick Coghlan ncogh...@gmail.com wrote: So I think I'd prefer flipping this around - you can't provide a custom registry mapping, but you *can* get access to a read only view of it through a registry attribute on the generic function. You guys convinced me. Both the

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Antoine Pitrou
On Sat, 25 May 2013 22:16:04 +0200 Łukasz Langa luk...@langa.pl wrote: On 25 maj 2013, at 17:13, Nick Coghlan ncogh...@gmail.com wrote: So I think I'd prefer flipping this around - you can't provide a custom registry mapping, but you *can* get access to a read only view of it through a

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread PJ Eby
On Sat, May 25, 2013 at 4:16 PM, Łukasz Langa luk...@langa.pl wrote: So, the latest document is live: http://www.python.org/dev/peps/pep-0443/ The code is here: http://hg.python.org/features/pep-443/file/tip/Lib/functools.py#l363 The documentation here:

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Nick Coghlan
On Sun, May 26, 2013 at 9:07 AM, PJ Eby p...@telecommunity.com wrote: On Sat, May 25, 2013 at 4:16 PM, Łukasz Langa luk...@langa.pl wrote: So, the latest document is live: http://www.python.org/dev/peps/pep-0443/ The code is here:

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Steven D'Aprano
On 26/05/13 09:07, PJ Eby wrote: Transforms a function into a single-dispatch generic function. A **generic function** is composed of multiple functions implementing the same operation for different types. Which implementation should be used during a call is determined by the dispatch

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Robert Kern
On 2013-05-25 09:18, Antoine Pitrou wrote: Hello, In http://bugs.python.org/issue17936, I proposed making tp_subclasses (the internal container implementing object.__subclasses__) a dict. This would make the return order of __subclasses__ completely undefined, while it is right now slightly

Re: [Python-Dev] __subclasses__() return order

2013-05-25 Thread Nick Coghlan
On Sat, May 25, 2013 at 11:49 PM, Łukasz Langa luk...@langa.pl wrote: I guess I should explain myself more clearly: __subclasses__() already computes its result on-the-fly (it must weed out dead weakrefs) (*). So the visible behaviour of __subclasses__ wouldn't change, except for ordering.