[Python-Dev] Re: Proto-PEP part 2: Alternate implementation proposal for "forward class" using a proxy object

2022-04-23 Thread Joao S. O. Bueno
So - good idea on creating the proxy. But would you really __need__ this badly that the proxy object would "become" the new class object, preserving its "id"? Just name re-binding (and the static type checkers _knowing_ the name will be re-assign to the actuall class object later) seems to be pr

[Python-Dev] Re: Proto-PEP part 2: Alternate implementation proposal for "forward class" using a proxy object

2022-04-23 Thread Joao S. O. Bueno
TL;DR (literally, I will go back and read it now, but after reading the first paragraphs: _a proxy_ object yes, then dividing class creation in 2 blocks would not break things) /me goes back to text. On Fri, Apr 22, 2022 at 10:20 PM Larry Hastings wrote: > > Here's one alternate idea for how

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Joao S. O. Bueno
On Sat, Apr 23, 2022 at 7:10 PM Paul Moore wrote: > On Sat, 23 Apr 2022 at 22:42, Rob Cliffe via Python-Dev > wrote: > > > > UGH! > > > > I thought there was a general understanding that when typing was added > > to Python, there would be no impact, or at least minimal impact, on > > people who

[Python-Dev] Re: Proto-PEP part 3: Closing thoughts on "forward class", etc.

2022-04-23 Thread Nick Coghlan
On Sat, 23 Apr 2022, 11:17 am Larry Hastings, wrote: > > > Just a quick note from me on the proto-PEP and the two proposed > implementations. When I started exploring this approach, I didn't suspect > it'd require such sweeping changes to be feasible. Specifically, I didn't > think I was going

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Paul Moore
On Sat, 23 Apr 2022 at 22:42, Rob Cliffe via Python-Dev wrote: > > UGH! > > I thought there was a general understanding that when typing was added > to Python, there would be no impact, or at least minimal impact, on > people who didn't use it. (Raises hand.) > Now we see an(other) instance of in

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Rob Cliffe via Python-Dev
UGH! I thought there was a general understanding that when typing was added to Python, there would be no impact, or at least minimal impact, on people who didn't use it.  (Raises hand.) Now we see an(other) instance of intention creep. Rob Cliffe On 23/04/2022 02:13, Larry Hastings wrote:

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/23/22 08:57, Eric V. Smith wrote: On 4/23/2022 9:55 AM, Jelle Zijlstra wrote: However, it doesn't solve the problem for base classes. For example, str is conceptually defined as `class str(Sequence["str"]):`. A forward reference can't make `str` defined when the bases are evaluated, be

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/23/22 06:55, Jelle Zijlstra wrote: So to reiterate, your proposal would be to write this as: forward class B:     pass class A:     value: B continue class B:     value: A Not quite; the "forward class" statement doesn't have a colon or a class body.  This would be written as: fo

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Eric V. Smith
On 4/23/2022 9:55 AM, Jelle Zijlstra wrote: However, it doesn't solve the problem for base classes. For example, str is conceptually defined as `class str(Sequence["str"]):`. A forward reference can't make `str` defined when the bases are evaluated, because bases are resolved at the `forward

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Eric V. Smith
On 4/23/2022 3:28 AM, Tobias HT wrote: On the other hand, there's something I've been seeing around. I don't know if it was introduced by Mypy or something, but its the use of declaration files. I think they are saved as pyi files. They just have the declaration of a python object, be it cla

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Tobias HT
This seems like it would solve a huge problem that I've often faced myself, but by introducing something that might later on cause problems I anticipate. Like some people suggested earlier, introducing new keyword in python is not a good solution, I feel it just adds to the already existing bulk a

[Python-Dev] Re: [Typing-sig] Almost accepting PEP 681 – Data Class Transforms

2022-04-23 Thread Jelle Zijlstra
El sáb, 23 abr 2022 a las 4:26, Petr Viktorin () escribió: > Hello, > As an initial implementation that will be improved in the future, the > specification in PEP 681 is fine. Feel free to add the decorator to > Python 3.11 at your convenience. > Thanks Petr, that's great to hear! I opened a PR

[Python-Dev] Re: Python multithreading without the GIL

2022-04-23 Thread brataodream
Hello all, I am very excited about a future multithreaded Python. I managed to postpone some rewrites in the company I work for Rust/Go, precisely because of the potential to have a Python solution in the medium term. I was wondering. Is Sam Gross' nogil merge being seriously considered by the

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Jelle Zijlstra
I don't think this proposal is a good solution for the problems of static typing users. El vie, 22 abr 2022 a las 18:16, Larry Hastings () escribió: > But the explosion of static type analysis in Python, particularly with > the `typing` module and the `mypy` tool, has made circular definition-tim

[Python-Dev] Almost accepting PEP 681 – Data Class Transforms

2022-04-23 Thread Petr Viktorin
Hello, As an initial implementation that will be improved in the future, the specification in PEP 681 is fine. Feel free to add the decorator to Python 3.11 at your convenience. However, the PEP includes several worrying recommendations like: - we recommend that the maintainers of attrs move

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
I should have said "numpy_forward", not "numpy.forward". I changed my mind at the last second as I was writing that email, and momentarily forgot that when you import x.y you implicitly import x. /arry On Sat, Apr 23, 2022, 01:53 Larry Hastings wrote: > > On 4/23/22 01:14, Steven D'Aprano wro

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/23/22 03:10, Terry Reedy wrote: On 4/22/2022 11:16 PM, Larry Hastings wrote: So I still prefer "forward class". I don't think it's as clear as "forward class" 'forward class' for an incomplete class is not at all clear to me.  It is not clear to me which part of speech you intend it t

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Terry Reedy
On 4/22/2022 11:16 PM, Larry Hastings wrote: So I still prefer "forward class". I don't think it's as clear as "forward class" 'forward class' for an incomplete class is not at all clear to me. It is not clear to me which part of speech you intend it to be: noun, verb, adjective, or adverb

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/23/22 01:14, Steven D'Aprano wrote: On Sat, Apr 23, 2022 at 12:46:37AM -0700, Larry Hastings wrote: But rather than speculate further, perhaps someone who works on one of the static type analysis checkers will join the discussion and render an informed opinion about how easy or hard it wo

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/23/22 00:53, Steven D'Aprano wrote: It's a "forward-declared class object".  It's the real class object, but it hasn't been fully initialized yet, and won't be until the "continue class" statement. The only thing that makes it not fully initialised is that it has a bozo bit dunder "__forwa

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Steven D'Aprano
On Sat, Apr 23, 2022 at 12:46:37AM -0700, Larry Hastings wrote: > But rather than speculate further, perhaps someone who works on one of > the static type analysis checkers will join the discussion and render an > informed opinion about how easy or hard it would be to support "forward > class"

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Steven D'Aprano
On Fri, Apr 22, 2022 at 10:09:33PM -0700, Larry Hastings wrote: [Larry] > >>To be clear: `forward class` creates the official, actual class object. > >>Code that wants to take a reference to the class object may take > >>references > >>to the `forward class` declared class, and interact with it a

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Larry Hastings
On 4/22/22 23:41, Mehdi2277 wrote: My main question for this approach is how would this work with type checkers? It would be new syntax for Python, so type checkers would have to understand it. Is there any restriction that forward class's continuation must appear in same module? No.

[Python-Dev] Re: Proto-PEP part 1: Forward declaration of classes

2022-04-23 Thread Steven D'Aprano
On Sat, Apr 23, 2022 at 06:41:23AM -, Mehdi2277 wrote: > My main question for this approach is how would this work with type > checkers? Is there any restriction that forward class's continuation > must appear in same module? If it's allowed that a forward class may > be continued in a dif