[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-31 Thread Chris Angelico
On Sun, Oct 31, 2021 at 4:50 AM Eric V. Smith wrote: > > On 10/30/2021 10:40 AM, Chris Angelico wrote: > > And, seeing something in help(fn) largely necessitates that the source > > code be retained. I don't know of any other way to do it. If you say > > that the default argument is "len(a)", then

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-31 Thread Jonathan Fine
Hi Chris Again you ask good questions. Q: How to find the bare string '#wibble'? It's optimised out during compilation. A: Very good. I didn't know that. For current Python we'll have to use a different marker. For future Python we could change the compiler so that it directly sets fn.__wibble__

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-31 Thread Chris Angelico
On Sun, Oct 31, 2021 at 7:01 PM Jonathan Fine wrote: > > Hi > > I've just had a brainwave that may give an even less invasive implementation > of PEP 671. It relies on every function having a dict, as provided by > https://www.python.org/dev/peps/pep-0232/. > > Consider: > def fn(a, b, c): p

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-31 Thread Jonathan Fine
Hi I've just had a brainwave that may give an even less invasive implementation of PEP 671. It relies on every function having a dict, as provided by https://www.python.org/dev/peps/pep-0232/. Consider: def fn(a, b, c): pass fn.__wibble__ = 123 fn.__wibble__ # Give 123, of course. No

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-30 Thread Eric V. Smith
On 10/30/2021 10:40 AM, Chris Angelico wrote: And, seeing something in help(fn) largely necessitates that the source code be retained. I don't know of any other way to do it. If you say that the default argument is "len(a)", then that's what help() should say. "from __future__ import annotation

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-30 Thread Jonathan Fine
Hi Chris I like your questions. You ask: How would fn.__wibble__ be different from checks at the top of fn.__code__? They'd be in two different code blocks. I see a function call going as follows. 1. Process the supplied arguments in the usual way. 2. Create a new frame object and place it on the

[Python-ideas] Re: PEP 671 proof-of-concept: A less invasive implementation

2021-10-30 Thread Chris Angelico
On Sat, Oct 30, 2021 at 10:32 PM Jonathan Fine wrote: > I suggest that an implementation which provides additional flexibility in the > manner in which the code frame is initialised would be less invasive. > Necessarily, PEP 671 allows programmer supplied code to be used in the > 'initialisatio