[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Terry Reedy

On 5/12/2021 1:40 PM, Mark Shannon wrote:

This is an informational PEP about a key part of our plan to improve 
CPython performance for 3.11 and beyond.


What is the purpose of this PEP?  It seems in part to be like a 
Standards Track PEP in that it proposes a new (revised) implementation 
idea for the CPython bycode interpreter.  Do you not intend this to not 
constitute approval of even the principle?


One of the issues in the new project gave formulas for the cost versus 
benefit calculations underlying specialization.  Depending on your 
purpose, it might be good to include them.  They certainly gave some 
clarity to me.


--
Terry Jan Reedy

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/I3UXYIMASCD5MDJ5QU6ITF6CRKIURHQ5/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Abdur-Rahmaan Janhangeer
Greetings,

One crucial missing piece in the Python world is the focus
on internals of projects. You have many talks on usage and
scaling but not enough on internals. Even less workshops.
For OpenSource to thrive, you need people who master the codebase.
It's a long process. You get there by having core contributors over
time. How does a contributor becomes a core one? By getting the feet wet
into the codebase and tackling more difficult as time passes. That's why
instead of waiting for people to find issues, work on it, wait for
validation,
we can improve the training process without damage to the codebase.
People get the educational version of the repo, solve the issues at their
own pace up to the level where they'll feel confident to try a meaningful
PR. Seeing it with the eye of a knowledgeable person makes will make them
PR not just for the sake of PR but because of a real need. One practical
way is also to point the intermediate steps to resources on the internet,
like
this and that C articles to get started with C, this article to understand
this C
behaviour, this talk at this conf to understand this part of the C API, i
built a
tool specifically to document those intermediate steps by gathering
resources
on the internet, will start using it soon: https://linkolearn.com/. I  am
part of the
Flask Community Workgroup (It's due to be announced soon, but here is the
link:
https://flaskcwg.github.io/). One of the aims of it is education, a good
deal about
internals. We aim to roll out some initiatives by next year. What caused me
to
write the first post is that there seems to be a bottleneck somewhere when
you
see contributors overwhelmed by OpenSource tasks. If it were some obscure
project
I understand but not one of the most popular OpenSource product of today.

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

github 
Mauritius
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/473YV6T3RVI55KA45LA5KIA7FXQHBSEY/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Chris Angelico
On Thu, May 13, 2021 at 5:37 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> Greetings,
>
> One crucial missing piece in the Python world is the focus
> on internals of projects. You have many talks on usage and
> scaling but not enough on internals. Even less workshops.
> For OpenSource to thrive, you need people who master the codebase.
> It's a long process. You get there by having core contributors over
> time. How does a contributor becomes a core one? By getting the feet wet
> into the codebase and tackling more difficult as time passes. That's why
> instead of waiting for people to find issues, work on it, wait for validation,
> we can improve the training process without damage to the codebase.
> People get the educational version of the repo, solve the issues at their
> own pace up to the level where they'll feel confident to try a meaningful
> PR. Seeing it with the eye of a knowledgeable person makes will make them
> PR not just for the sake of PR but because of a real need.

How is this "educational version" different from a forked git
repository? I'm confused here.

ChrisA
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/N2BUH2MHDTPERNA4TLCXQOL5KQ5FFL3D/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Abdur-Rahmaan Janhangeer
Greetings,

On Thu, May 13, 2021 at 11:43 AM Chris Angelico  wrote:

> How is this "educational version" different from a forked git
> repository? I'm confused here.
>

Oh i mean a forked git repository with internal-focused documentations,
issues
opened with description of changes to be made then repo set to READONLY.
A way to view what the solved issues look like in included under
'internal-focused documentations'

Kind Regards,

Abdur-Rahmaan Janhangeer
about  | blog

github 
Mauritius
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/6DFH2ZVEZ6HYQTYZYZYEG3FZT3KN67G6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Mark Shannon

Hi Terry,

On 13/05/2021 5:32 am, Terry Reedy wrote:

On 5/12/2021 1:40 PM, Mark Shannon wrote:

This is an informational PEP about a key part of our plan to improve 
CPython performance for 3.11 and beyond.



As always, comments and suggestions are welcome.


The claim that starts the Motivation section, "Python is widely 
acknowledged as slow.", has multiple problems. While some people 
believe, or at least claim to believe "Python is slow", other know that 
as stated, the latter is false.  Languages do not have a speed, only 
implementations running code for particular applications have a speed, 
or a speed relative to equivalent code in another language with a 
different runtime.


I broadly agree, but CPython is largely synonymous with Python and 
CPython is slower than it could be.


The phrase was not meant to upset anyone.
How would you rephrase it, bearing in mind that needs to be short?



I reason I am picking on this is that the meme 'Python is slow' is being 
morphed into 'Python is destroying the earth' (and should be abandoned, 
if not banned).  Last fall, a science news journal (Nature News?) quoted 
a 'concerned scientist' saying just this.  An internet troll repeated it 
last week on comp.lang.python (from where it leaked onto python-list).


It is a legitimate concern that CPython is bad for the environment, and 
one that I hope we can address by speeding up CPython.


Since, faster == less energy for the same amount of work, making CPython 
faster will reduce the amount of CO2 produced to do that work and 
hopefully make it less of a concern.


Of course, compared to the environmental disaster that is BitCoin, it's 
not a big deal.




It is true that Python has characteristics that make it *relatively* 
difficult to write interpreters that are *relatively* fast in certain 
applications.  But the opposite is also true.  The language does *not* 
mandate that objects, their methods, and modules be written in the 
language.


Hence, CPython implements builtin objects and function and some stdlib 
modules in C and allows 3rd party modules written in C or C++ or 
Fortran. I believe the first killer app for Python, in the mid 1990s, 
numerical computing with NumericalPython.  Rather than being 'slow', 
CPython *enabled* people, with a few percent of added time, to access 
fast, heavily optimized C and Fortran libraries and do things they could 
not do in Fortran and that would have been much more difficult in C.  My 
daughter's PhD thesis work is a recent example of using Python to access 
C libraries.


Yes, one of the great things about Python is that almost every library 
of any size has Python bindings.


But there is a difference between making code that is already written in 
C/Fortran available to Python and telling people to write code in 
C/Fortran because their Python code is too slow.


We want people to be able to write code in Python and have it perform at 
the level they would get from a good Javascript or lua implementation.




The concerned scientist mentioned above noted, more or less correctly, 
that numerical code, such as neuro-network code, is, say, 80x slower in 
pure python than in compiled C.  But he did not mention that serious 
numerical and scientific work in Python is not done with such code.

I have seen this sort of bogus comparison before.


It is still important to speed up Python though.

If a program does 95% of its work in a C++ library and 5% in Python, it 
can easily spend the majority of its time in Python because CPython is a 
lot slower than C++ (in general).


Cheers,
Mark.




https://www.python.org/dev/peps/pep-0659/



___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/QAWW7I733TPNU4VE2I4J2FCPCXXVM7MG/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Paul Moore
On Thu, 13 May 2021 at 09:23, Mark Shannon  wrote:
>
> Hi Terry,
>
> On 13/05/2021 5:32 am, Terry Reedy wrote:
> > On 5/12/2021 1:40 PM, Mark Shannon wrote:
> >
> >> This is an informational PEP about a key part of our plan to improve
> >> CPython performance for 3.11 and beyond.
> >
> >> As always, comments and suggestions are welcome.
> >
> > The claim that starts the Motivation section, "Python is widely
> > acknowledged as slow.", has multiple problems. While some people
> > believe, or at least claim to believe "Python is slow", other know that
> > as stated, the latter is false.  Languages do not have a speed, only
> > implementations running code for particular applications have a speed,
> > or a speed relative to equivalent code in another language with a
> > different runtime.
>
> I broadly agree, but CPython is largely synonymous with Python and
> CPython is slower than it could be.
>
> The phrase was not meant to upset anyone.
> How would you rephrase it, bearing in mind that needs to be short?

How about simply "The CPython interpreter, while sufficiently fast for
much use, could be faster"? Along with the following sentence, this
seems to me to state the situation fairly but in a way that motivates
this proposal.

Paul
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/UQFXWM64JORKYJVAGIOV6YJ5OWDTTQRA/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Mark Shannon

Hi Terry,

On 13/05/2021 8:20 am, Terry Reedy wrote:

On 5/12/2021 1:40 PM, Mark Shannon wrote:

This is an informational PEP about a key part of our plan to improve 
CPython performance for 3.11 and beyond.


What is the purpose of this PEP?  It seems in part to be like a 
Standards Track PEP in that it proposes a new (revised) implementation 
idea for the CPython bycode interpreter.  Do you not intend this to not 
constitute approval of even the principle?


I will make it a standards PEP if anyone feels that would be better.
We can implement PEP 659 incrementally, without any large changes to the 
implementation or any to the language or API/ABI, so a standards PEP 
didn't seem necessary to us.


However, because it is a large change to the implementation, it seemed 
worth documenting and doing so in a clearly public fashion. Hence the 
informational PEP.




One of the issues in the new project gave formulas for the cost versus 
benefit calculations underlying specialization.  Depending on your 
purpose, it might be good to include them.  They certainly gave some 
clarity to me.




Which ones in particular? I can add something like them to the PEP.

Cheers,
Mark.


___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/VY3JB3XO4D2E65ZR5IZUDP7MFQJ3JXIF/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Chris Jerdonek
On Wed, May 12, 2021 at 10:48 AM Mark Shannon  wrote:

> ...
> For those of you aware of the recent releases of Cinder and Pyston,
> PEP 659 might look similar.
> It is similar, but I believe PEP 659 offers better interpreter
> performance and is more suitable to a collaborative, open-source
> development model.
>

I was curious what you meant by "is more suitable to a collaborative,
open-source
development model," but I didn't see it elaborated on in the PEP. If this
is indeed a selling point, it might be worth mentioning that and saying why.

--Chris


> As always, comments and suggestions are welcome.
>
> Cheers,
> Mark.
>
> Links:
>
> https://www.python.org/dev/peps/pep-0659/
> https://github.com/facebookincubator/cinder
> https://github.com/pyston/pyston
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/VKBV4X6ZEMRBALW7JNOZYI22KETR4F3R/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/NGDXMGDYQQSJO73WOPSQO7GM4OXDKI73/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] The repr of a sentinel

2021-05-13 Thread Irit Katriel via Python-Dev
Following a recent change, we now have in traceback.py:

_sentinel = object()
def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None,
file=None, chain=True):

So now:

>>> import traceback
>>> help(traceback.print_exception)
Help on function print_exception in module traceback:

print_exception(exc, /, value=, tb=,
limit=None, file=None, chain=True)


Is there a convention on how such default sentinel values should appear in
docs?

https://bugs.python.org/issue43024
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/ZLVPD2OISI7M4POMTR2FCQTE6TPMPTO3/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Antoine Pitrou
On Thu, 13 May 2021 10:15:03 +0100
Irit Katriel via Python-Dev  wrote:

> Following a recent change, we now have in traceback.py:
> 
> _sentinel = object()
> def print_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None,
> file=None, chain=True):
> 
> So now:
> 
> >>> import traceback
> >>> help(traceback.print_exception)  
> Help on function print_exception in module traceback:
> 
> print_exception(exc, /, value= 0x02825DF09650>, tb=,  
> limit=None, file=None, chain=True)
> 
> 
> Is there a convention on how such default sentinel values should appear in
> docs?

If this were a positional-only argument, you could use square brackets,
e.g.:

  print_exception(exc[, value[, ...]])

Other than that, I can't think of any existing convention.  I agree
that  is a reasonable spelling.

Regards

Antoine.


___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/EJXKQJM7COQFIPPSQGH5O3IAFPUKYWGL/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Irit Katriel via Python-Dev
On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou  wrote:

>
>  I agree that  is a reasonable spelling.
>
>
I initially suggested , but now I'm not sure because it doesn't
indicate what happens when you don't provide it (as in, what is the default
value).  So now I'm with  or .

The arg is only there for backwards compatibility now.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/C5W6NT6KYF2M2QW2WZZ6V33KTMIVICDY/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Antoine Pitrou


Le 13/05/2021 à 11:40, Irit Katriel a écrit :



On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou > wrote:



  I agree that  is a reasonable spelling.


I initially suggested , but now I'm not sure because it 
doesn't indicate what happens when you don't provide it (as in, what is 
the default value).  So now I'm with  or .


"" makes think of a derived class, and leaves me confused. 
"" is a bit better, but doesn't clearly say what the default 
value is, either.  So in all cases I have to read the docstring in 
addition to the function signature.


Regards

Antoine.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/EVACPXULASJ2GUTN7ZICKJ2LOT224MP4/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Steve Holden
On Thu, May 13, 2021 at 9:18 AM Mark Shannon  wrote:

> Hi Terry,
>
> On 13/05/2021 5:32 am, Terry Reedy wrote:
> > On 5/12/2021 1:40 PM, Mark Shannon wrote:
> >
> >> This is an informational PEP about a key part of our plan to improve
> >> CPython performance for 3.11 and beyond.
> >
> >> As always, comments and suggestions are welcome.
> >
> > The claim that starts the Motivation section, "Python is widely
> > acknowledged as slow.", has multiple problems. While some people
> [...]

> different runtime.
>
> I broadly agree, but CPython is largely synonymous with Python and
> CPython is slower than it could be.
>
> The phrase was not meant to upset anyone.
> How would you rephrase it, bearing in mind that needs to be short?
>
> "There is broad interest in improving the performance of pure Python code.
[optionally: The integration of powerful numerical and other algorithms
already makes Python competitive at intensive computations, but programmers
whose main interest is in solving non-programming problems cannot
generally create such solutions.]"

[...]

hopefully make it less of a concern.
>
> Of course, compared to the environmental disaster that is BitCoin, it's
> not a big deal.


Every little helps. Please switch off the light as you leave the room.

[...]

> It is still important to speed up Python though.
>
> Agreed.


> If a program does 95% of its work in a C++ library and 5% in Python, it
> can easily spend the majority of its time in Python because CPython is a
> lot slower than C++ (in general).
>
> That's a pretty loose statement, but I see no reason to quibbe about the
details. There's room for improvement, and improvement will be welcome.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/XCQ7OHDJRIR5WYIHHURHOJYW4NW6RNBZ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Petr Viktorin

On 13. 05. 21 11:45, Antoine Pitrou wrote:


Le 13/05/2021 à 11:40, Irit Katriel a écrit :



On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou > wrote:



  I agree that  is a reasonable spelling.


I initially suggested , but now I'm not sure because it 
doesn't indicate what happens when you don't provide it (as in, what 
is the default value).  So now I'm with  or .


"" makes think of a derived class, and leaves me confused. 
"" is a bit better, but doesn't clearly say what the default 
value is, either.  So in all cases I have to read the docstring in 
addition to the function signature.




Is  the term you're looking for?
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/POF7BUF5EGU37DB5F34DOVT7E6LVERX4/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Steven D'Aprano
On Thu, May 13, 2021 at 09:18:27AM +0100, Mark Shannon wrote:

> Since, faster == less energy for the same amount of work, making CPython 
> faster will reduce the amount of CO2 produced to do that work and 
> hopefully make it less of a concern.

Work expands to fill the time available: if Python is 10% more 
efficient, people will use that extra speed to do 10% more work. There 
will be no nett savings in CO2 and if anything a faster Python will lead 
to more people using it and hence a nett increase in Python's share of 
the CO2 emissions.

Let's make Python faster, but don't fool ourselves that we're doing it 
for the environment. Every time people improve the efficiency of some 
resource, we respond by using more of that resource.


-- 
Steve
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/KWKEBEW5U6CTBQCBDEHBD62WHNZYQ33P/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Steve Dower

On 13May2021 1248, Petr Viktorin wrote:

On 13. 05. 21 11:45, Antoine Pitrou wrote:


Le 13/05/2021 à 11:40, Irit Katriel a écrit :



On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou > wrote:



  I agree that  is a reasonable spelling.


I initially suggested , but now I'm not sure because it 
doesn't indicate what happens when you don't provide it (as in, what 
is the default value).  So now I'm with  or .


"" makes think of a derived class, and leaves me confused. 
"" is a bit better, but doesn't clearly say what the default 
value is, either.  So in all cases I have to read the docstring in 
addition to the function signature.




Is  the term you're looking for?


Perhaps  or ?

Cheers,
Steve
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/RSRBWH2UK2MKZN7O3PHSNVZFZEE7JIVJ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Eric V. Smith

On 5/13/2021 7:48 AM, Petr Viktorin wrote:

On 13. 05. 21 11:45, Antoine Pitrou wrote:


Le 13/05/2021 à 11:40, Irit Katriel a écrit :



On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou > wrote:



  I agree that  is a reasonable spelling.


I initially suggested , but now I'm not sure because it 
doesn't indicate what happens when you don't provide it (as in, what 
is the default value).  So now I'm with  or .


"" makes think of a derived class, and leaves me confused. 
"" is a bit better, but doesn't clearly say what the 
default value is, either.  So in all cases I have to read the 
docstring in addition to the function signature.




Is  the term you're looking for? 


In the dataclasses docs 
https://docs.python.org/3/library/dataclasses.html I document the 
module-level sentinel MISSING, then I document the function as:


dataclasses.field(*, default=MISSING, default_factory=MISSING, 
repr=True, hash=None, init=True, compare=True, metadata=None)


And I explain what MISSING means.

The help looks like:

field(*, default=, 
default_factory=, 
init=True, repr=True, hash=None, compare=True, metadata=None)


None of this is particularly awesome, but no one has complained about it 
yet.


I think it's important to state an actual value for the default value, 
instead of just using something like "". Unless you know the 
actual default value, you can't write a wrapper.


Say I wanted to write something that calls dataclasses.field, but 
doesn't allow the user to specify repr, hash, init, compare, and 
metadata. I could write it as:


def myfield_func(*, default=MISSING, default_factory=MISSING):
    ...

If the real default values for "default" and "default_factory" weren't 
documented, there wouldn't be any easy way to write this.


I do think a python-wide standard for this would be helpful, but I don't 
see how to change existing code given backward compatibility constraints.


Eric

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/ICKR43MC35QNBEWZLJ6NW2RG2M4O27FU/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Tal Einat
On Thu, May 13, 2021 at 4:31 PM Eric V. Smith  wrote:
>
> I do think a python-wide standard for this would be helpful, but I don't
> see how to change existing code given backward compatibility constraints.

While we're on the subject, these sentinels also don't compare
properly using `is` after pickling and unpickling.

I think it's worth considering making the sentinels in the stdlib all
have good reprs and support pickling+unpickling.

What would be the potential backwards-compatibility issues with
changing the implementation of these existing sentinel values?

- Tal
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/KKDZ5TW6WXSQDE2YPOU6X5JXEU264HBS/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Future PEP: Include Fine Grained Error Locations in Tracebacks

2021-05-13 Thread Barry


> On 13 May 2021, at 02:09, Mike Miller  wrote:
> 
> 
>> On 2021-05-11 16:12, Guido van Rossum wrote:
>> On Tue, May 11, 2021 at 4:07 PM Gregory P. Smith > There's a difference between tracebacks dumped as plain text (utf-8) by
>>traceback.print_exc() appearing on stderr or directed into log files and
>>what can be displayed within a terminal.  It is highly unusual to emit
>>terminal control characters into log files.
>> And yet it happens all the time. :-( Let's not risk that happening.
> 
> 
> os.isatty() is helpful in that situation, 

Most tools that support colour output allow you to customise the colours
and have a always-colour, never-colour, auto-colour option.

Isatty() is useful for the auto.

Barry

> 
> -Mike
> 
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at 
> https://mail.python.org/archives/list/[email protected]/message/QT2CTAPV7BVUHEUR6OY6DKWTNX6WM5MF/
> Code of Conduct: http://python.org/psf/codeofconduct/

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/I5A6JSFVERDC6YG6CNHSJQTY4CDUTSY6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Eric V. Smith

On 5/13/2021 10:02 AM, Tal Einat wrote:

On Thu, May 13, 2021 at 4:31 PM Eric V. Smith  wrote:

I do think a python-wide standard for this would be helpful, but I don't
see how to change existing code given backward compatibility constraints.

While we're on the subject, these sentinels also don't compare
properly using `is` after pickling and unpickling.

I think it's worth considering making the sentinels in the stdlib all
have good reprs and support pickling+unpickling.

What would be the potential backwards-compatibility issues with
changing the implementation of these existing sentinel values?


I don't think there would be a problem changing the implementation. I 
was commenting on changing the name of the sentinel objects so that we 
could document the functions with the sentinel's real name. We couldn't 
change them to all be some appropriate module-level value named 
"MISSING", for example.


Eric

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/SWGCTZFNGLFEQ5SL5GBVQFQAD2YAAZNI/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Antoine Pitrou
On Thu, 13 May 2021 13:44:54 +0100
Steve Dower  wrote:
> On 13May2021 1248, Petr Viktorin wrote:
> > On 13. 05. 21 11:45, Antoine Pitrou wrote:  
> >>
> >> Le 13/05/2021 à 11:40, Irit Katriel a écrit :  
> >>>
> >>>
> >>> On Thu, May 13, 2021 at 10:28 AM Antoine Pitrou  >>> > wrote:
> >>>
> >>>
> >>>   I agree that  is a reasonable spelling.
> >>>
> >>>
> >>> I initially suggested , but now I'm not sure because it 
> >>> doesn't indicate what happens when you don't provide it (as in, what 
> >>> is the default value).  So now I'm with  or .  
> >>
> >> "" makes think of a derived class, and leaves me confused. 
> >> "" is a bit better, but doesn't clearly say what the default 
> >> value is, either.  So in all cases I have to read the docstring in 
> >> addition to the function signature.
> >>  
> > 
> > Is  the term you're looking for?  
> 
> Perhaps  or ?

Now that I read more about the specific use case, though, I think
"" really describes it accurately.  It's not that the
information is missing, it's that it's already implied in another
argument.

Quoting the documentation:

"""Since Python 3.10, instead of passing value and tb, an exception object
can be passed as the first argument."""

(meaning the traceback is implicitly gotten from the exception object
which is passed as first argument)

Regards

Antoine.


___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/BROL74WPPOLTJLSRER6NLWUJRU3JK4SE/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Stéfane Fermigier
On Wed, May 12, 2021 at 8:51 PM Abdur-Rahmaan Janhangeer <
[email protected]> wrote:

> Great news, just a tiny bit from me.
> I read the other day in the OpenSource report
> sponsored by the Ford Foundation a CPython
> contributor stating that we have an all time high
> count of Python users but an all time low number of
> contributors to CPython.
>

There's also (probably, I didn't count myself) a record number of Python
implementations that are not CPython (including Cython, Pythran and similar
projects) as well as CPython forks (Pyjion, Pyston, the project announced
by Guido, etc.)

Also: judging from https://github.com/python/cpython/graphs/contributors,
the "all time low number of contributors to CPython" assertion doesn't seem
to hold. In terms of committers, and according to this page, I count a
similar number or slightly higher of committers (50+) over the last year,
similar to over previous years (including those that seem more active in
terms of commit counts on the graph, like around 2010).

  S.

-- 
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier -
http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software -
http://www.abilian.com/
Chairman, National Council for Free & Open Source Software (CNLL) -
http://cnll.fr/
Founder & Organiser, PyParis & PyData Paris - http://pyparis.org/ &
http://pydata.fr/
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/IVNEVZE6Z25EHXWNE5RKJPZDIU3LVKWC/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Stéfane Fermigier
On Thu, May 13, 2021 at 8:42 AM Abdur-Rahmaan Janhangeer <
[email protected]> wrote:

> Actual quote by "a Python Software Foundation fellow and contrib-
> utor to Python infrastructure projects"
>

Ah, this is what you were referring to. The document was published 5 years
ago, so this may or may not reflect the current situation.


> What frustrates me most is that we have an all-time high of
> Python developers and an all-time low on high quality contri-
> butions.[...] As soon as pivotal developers like Armin Ronacher
> slow down their churn, the whole community feels it immedi-
> ately.
>

That's true, but, AFAIK, Armin was never a direct contributor to CPython
(confirmed by looking at
https://github.com/python/cpython/graphs/contributors ) so I guess that's
another issue.


But to add a specific comment on this topic: Armin was indeed a very
creative and prolific developer of Python libraries and frameworks, and
since he's mostly left the Python world this has been an issue indeed. Some
of his projects, like Lektor (which I'm using for my blog) have lost their
traction and some of their users are moving to other tools.

But the good news is that some of his projects have been picked up by other
contributors, as the "Pallets" project, and, as a coincidence, they have
made major new releases of most of Armin's old projects just a couple of
days ago: https://www.palletsprojects.com/blog/flask-2-0-released/

   S.

>

-- 
Stefane Fermigier - http://fermigier.com/ - http://twitter.com/sfermigier -
http://linkedin.com/in/sfermigier
Founder & CEO, Abilian - Enterprise Social Software -
http://www.abilian.com/
Chairman, National Council for Free & Open Source Software (CNLL) -
http://cnll.fr/
Founder & Organiser, PyParis & PyData Paris - http://pyparis.org/ &
http://pydata.fr/
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/NQGHCOCXSKY75GXH6DN2KGCMFRMQA6DA/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Christopher Barker
I suggest we keep it really simple, and name the implementation.

Building on Steve Holden’s suggestion:

There is broad interest in improving the performance of the cPython
runtime. (Interpreter?)

-CHB


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/XBHAAZIHYPTPBOMNIYQOKZRIIDSTSKSW/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Ethan Furman


On 5/13/21 2:15 AM, Irit Katriel via Python-Dev wrote:
>
>  >>> help(traceback.print_exception)
>  Help on function print_exception in module traceback:
>
>  print_exception(exc, /, value=, 
tb=  at 0x02825DF09650>, limit=None, file=None, 
chain=True)


On 5/13/21 5:37 AM, Eric V. Smith wrote:
>
> The help looks like:
>
>  field(*, default=,
>default_factory=,
>init=True, repr=True, hash=None, compare=True, metadata=None)
>
> None of this is particularly awesome, but no one has complained about it yet.

Consider me complaining.  ;-)

Looks to me like the default repr for the sentinels is making those helps much less helpful by showing totally 
irrelevant information and cluttering up the screen making it harder to see the actually useful bits.


An actual Sentinel class would be helpful:

>>> class Sentinel:
... def __init__(self, repr):
... self.repr = repr
... def __repr__(self):
... return self.repr
...

>>> MISSING = Sentinel('MISSING')
>>> MISSING
MISSING

>>> implicit = Sentinel('')
>>> implicit


Naturally, since sentinels are symbolic names, I think it should go into the enum module.  ;-)  Although I will concede 
that we could just put those five lines into the modules that need it.


--
~Ethan~
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/7S5PU6334ZZXCA3EFV244YZWY27KA3FD/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Guido van Rossum
Have you heard of this book? It's an excellent companion to the source code.

https://realpython.com/products/cpython-internals-book/

On Thu, May 13, 2021 at 12:30 AM Abdur-Rahmaan Janhangeer <
[email protected]> wrote:

> Greetings,
>
> One crucial missing piece in the Python world is the focus
> on internals of projects. You have many talks on usage and
> scaling but not enough on internals. Even less workshops.
> For OpenSource to thrive, you need people who master the codebase.
> It's a long process. You get there by having core contributors over
> time. How does a contributor becomes a core one? By getting the feet wet
> into the codebase and tackling more difficult as time passes. That's why
> instead of waiting for people to find issues, work on it, wait for
> validation,
> we can improve the training process without damage to the codebase.
> People get the educational version of the repo, solve the issues at their
> own pace up to the level where they'll feel confident to try a meaningful
> PR. Seeing it with the eye of a knowledgeable person makes will make them
> PR not just for the sake of PR but because of a real need. One practical
> way is also to point the intermediate steps to resources on the internet,
> like
> this and that C articles to get started with C, this article to understand
> this C
> behaviour, this talk at this conf to understand this part of the C API, i
> built a
> tool specifically to document those intermediate steps by gathering
> resources
> on the internet, will start using it soon: https://linkolearn.com/. I  am
> part of the
> Flask Community Workgroup (It's due to be announced soon, but here is the
> link:
> https://flaskcwg.github.io/). One of the aims of it is education, a good
> deal about
> internals. We aim to roll out some initiatives by next year. What caused
> me to
> write the first post is that there seems to be a bottleneck somewhere when
> you
> see contributors overwhelmed by OpenSource tasks. If it were some obscure
> project
> I understand but not one of the most popular OpenSource product of today.
>
> Kind Regards,
>
> Abdur-Rahmaan Janhangeer
> about  | blog
> 
> github 
> Mauritius
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/ZKL3FNUVSOUDONH53HUXWUWVKW7SJQU6/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Tal Einat
On Thu, May 13, 2021 at 7:44 PM Ethan Furman  wrote:
>
> Consider me complaining.  ;-)

+1

> An actual Sentinel class would be helpful:
>
>  >>> class Sentinel:
>  ... def __init__(self, repr):
>  ... self.repr = repr
>  ... def __repr__(self):
>  ... return self.repr
>  ...
>
>  >>> MISSING = Sentinel('MISSING')
>  >>> MISSING
>  MISSING
>
>  >>> implicit = Sentinel('')
>  >>> implicit
>  

Here is my suggestion (also posted on the related bpo-44123), which is
also simple, ensures a single instance is used, even considering
multi-threading and pickling, and has a better repr:

class Sentinel:
def __new__(cls, *args, **kwargs):
raise TypeError(f'{cls.__qualname__} cannot be instantiated')

class MISSING(Sentinel):
pass

- Tal
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/URFRF634732GRICGLRPGJEJON2BYQZM4/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Eric V. Smith

On 5/13/2021 12:41 PM, Ethan Furman wrote:



On 5/13/21 2:15 AM, Irit Katriel via Python-Dev wrote:


 >>> help(traceback.print_exception)
 Help on function print_exception in module traceback:

 print_exception(exc, /, value=0x02825DF09650>, tb= at 0x02825DF09650>, limit=None, file=None, 
chain=True)



On 5/13/21 5:37 AM, Eric V. Smith wrote:


The help looks like:

 field(*, default=0x6fe46610>,
   default_factory=0x6fe46610>,

   init=True, repr=True, hash=None, compare=True, metadata=None)

None of this is particularly awesome, but no one has complained about 
it yet.


Consider me complaining.  ;-)


Your complaint is hereby noted!

Looks to me like the default repr for the sentinels is making those 
helps much less helpful by showing totally irrelevant information and 
cluttering up the screen making it harder to see the actually useful 
bits.


An actual Sentinel class would be helpful:

   >>> class Sentinel:
   ... def __init__(self, repr):
   ... self.repr = repr
   ... def __repr__(self):
   ... return self.repr
   ...

   >>> MISSING = Sentinel('MISSING')
   >>> MISSING
   MISSING

dataclasses.py actually has similar code, but for some reason I guess it 
got missed for MISSING (ha!).


Naturally, since sentinels are symbolic names, I think it should go 
into the enum module.  ;-)  Although I will concede that we could just 
put those five lines into the modules that need it. 


Yeah, it's probably not worth dataclasses importing enum just to get 
that functionality.


Eric

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/45RGCWZJSS7WDWCYUEDL72NNHSYGGLCU/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Eric V. Smith



On 5/13/2021 1:39 PM, Tal Einat wrote:

On Thu, May 13, 2021 at 7:44 PM Ethan Furman  wrote:

Consider me complaining.  ;-)

+1


An actual Sentinel class would be helpful:

  >>> class Sentinel:
  ... def __init__(self, repr):
  ... self.repr = repr
  ... def __repr__(self):
  ... return self.repr
  ...

  >>> MISSING = Sentinel('MISSING')
  >>> MISSING
  MISSING

  >>> implicit = Sentinel('')
  >>> implicit
  

Here is my suggestion (also posted on the related bpo-44123), which is
also simple, ensures a single instance is used, even considering
multi-threading and pickling, and has a better repr:

class Sentinel:
 def __new__(cls, *args, **kwargs):
 raise TypeError(f'{cls.__qualname__} cannot be instantiated')

class MISSING(Sentinel):
 pass


>>> MISSING


I think a repr of just "MISSING", or maybe "dataclasses.MISSING" would 
be better.


Eric

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/EQZV3KZZQNBN6NQRIERUK5HOEAUW2DUJ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Stephen J. Turnbull
Abdur-Rahmaan Janhangeer writes:

 > No i mean fake path in the sense of a fork
 > of CPython with issues for learning purposes

*Creating* plausible issues is hard work, I assure you as a university
professor.  Coming up with "exercises" that are not makework requires
expertise in both the domain and in educational psychology.  (Some
people are "just good at it", of course, but it's quite clear from
popular textbooks that most are not.)  I think that would be a very
unproductive use of developer time, especially since "git clone; git
checkout some-tag-in-2017" is pretty much what you're asking for
otherwise.

 > Then people work on solving the issues on their
 > own without PRing.

The problem is not a lack of issues to practice on.  It's that (1) the
PR process itself is a barrier, or at least an annoyance, and (2) many
new contributors need mentoring.  (Or think they do.  Some just need
encouragment, others need help on technique, but both groups are more
or less blocked without the mentoring.)

And, of course, real contribution involves a lot of unfun work.
Writing tests, writing documentation, explaining to other developers
who start out -1 because they don't get it, overcoming your own mental
blocks to changing your submission because *you* don't get it, and on
and on.  A lot of newcomers think "I'm not good at that, if I have to
do it I can't contribute" (and a few selfishly think they can just do
the fun parts and achieve fame and fortune), but you know, "if not
you, then who?  If you don't do it for Python, where are you going to
be able to contribute?"

To be honest, although I'm not a specialist in organizational behavior
and am operating with a small sample, I can say that from the point of
view of identifying tasks, finding solutions, and implementing them,
Python is the most effective non-hierarchical organization I've ever
seen.  I can't say I've seen more than one or two hierarchical
organizations that are significantly better at implementing solutions
and don't burn up their workers in the process -- and the ones I'm
thinking of are way smaller than Python.  (Yes, I know that there are
people who have gotten burned up in Python, too.  We can do better on
that, but Python does not deliberately sacrifice people to the
organization.)

ISTM that Terry is right.  What we need to do better is encourage
people to just start contributing, and help them to get over the
initial humps: git, the PR process, requests from the QA police for
docs and tests and NEWS entries, etc.  Terry's approach seems good to
me on the face of it, and it's "battle-tested".  Terry uses it and has
had some successes.  Maybe that process can be tweaked, but it's a
good recipe.

I suspect that the main reason it doesn't work for Terry outside of
IDLE is that IDLE is where Terry has expertise and motivation to do
emotional work: handholding at the beginning, deeper involvement in
mentoring as necessary.  *And that's as it should be.*  It's up to the
rest of us to do that work on areas *we* care about.

I have to point out that there's a whole crew over on corementorship
doing this work, and at least one Very Senior Developer with their own
private mentoring program.[1]  IMO, that is a big part of why Python
is as successful as it is.  If more senior developers would take on
these tasks it would have a big effect downstream.  But emotional work
is hard, and it comes in big chunks.  In many situations you have to
follow through, on the mentee's schedule, or the mentee will "slip the
hook and swim away."  So it's a big ask.  I'm willing to make that ask
in the abstract, but there's not even one senior developer I'm able to
point to and say "definitely that person would do more for Python by
mentoring than by hacking".  It's a very hard problem.

Footnotes: 
[1]  Why "private"?  Well, why should the junior developers have all
the fun?  The VSDs want to hack too!  So those programs are small and
not terribly well-publicized (and they often have strong "inclusion"
focuses as well as specific focus on areas of improvement).

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/VZVIARBQRT3UGOY5RLJB35MUXWGLDYD5/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Fabio Zadrozny
Em qua., 12 de mai. de 2021 às 14:45, Mark Shannon 
escreveu:

> Hi everyone,
>
> I would like to present PEP 659.
>
> This is an informational PEP about a key part of our plan to improve
> CPython performance for 3.11 and beyond.
>
> For those of you aware of the recent releases of Cinder and Pyston,
> PEP 659 might look similar.
> It is similar, but I believe PEP 659 offers better interpreter
> performance and is more suitable to a collaborative, open-source
> development model.
>
> As always, comments and suggestions are welcome.
>
>
Hi Mark,

I think this seems like a nice proposal... I do have some questions related
to the PEP though (from the point of view of implementing a debugger over
it some things are kind of vague to me):

1. When will the specialization happen? (i.e.: is bytecode expected to be
changed while the code is running inside a frame or must it all be done
prior to entering a frame on a subsequent call?)

2. When the adaptive specialization happens, will that be reflected on the
actual bytecode seen externally in the frame or is that all internal? Will
clients be able to make sense of that? -- i.e.: In the debugger right now I
have a need on some occasions to detect the structure of the code from the
bytecode itself (for instance to detect whether some exception would be
handled or unhandled at raise time just given the bytecode).

3. Another example: I'm working right now on a feature to step into a
method. To do that right now my approach is:
- Compute the function call names and bytecode offsets in a given frame.
- When a frame is called (during a frame.f_trace call), check the
parent frame bytecode offset (frame.f_lasti) to detect if the last thing
was the expected call (and if it was, break the execution).

This seems reasonable given the current implementation, where bytecodes are
all fixed and there's a mapping from the frame.f_lasti ... Will that still
work with the specializing adaptive interpreter?

4. Will it still be possible to change the frame.f_code prior to execution
from a callback set in `PyThreadState.interp.eval_frame` (which will change
the code to add a breakpoint to the bytecode and later call
`_PyEval_EvalFrameDefault`)? Note: this is done in the debugger so that
Python can run without any tracing until the breakpoint is hit (tracing is
set afterwards to actually pause the execution as well as doing step
operations).

Best regards,

Fabio
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/SP4LXKA2Y3LUCEGDUUX2RB3ZWM2JICKB/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: Speeding up CPython

2021-05-13 Thread Mats Wichmann

On 5/12/21 4:10 PM, Terry Reedy wrote:

On 5/12/2021 5:14 PM, Antoine Pitrou wrote:

On Wed, 12 May 2021 17:05:03 -0400
Terry Reedy  wrote:



Yet you always see it: new people not knowing where to start,
highly skilled contributors drowning and
intermediate contributors moving slowly


I have multiple times strongly recommended that people review issues and
PRs, and sometimes given details, but most won't or don't.


I don't know who "people" are in your sentence, but reviewing issues
and PRs generally requires a high familiarity with a project, and


Much can be done without what I think you mean by 'high familiarity'.

Bug issues:
   bpo: "On macOS with 3.8.3 I see this buggy behavior" If not enough 
info to reproduce, ask for it.  If there is, try to reproduce on lastest 
release or even better, repository build.  Sometimes, trying on a 
different OS is helpful.

   PR: make local PR branch and test whether proposed fix works.

Enhancement issues:
   bpo: if proposal is for core python or a module one has used, does 
proposal seem like an actual improvement?  enough to be worth the likely 
bother?

   PR: does the PR work as promised?  Do you like it?

PR Python code: read it.  See any possible improvements?


In addition, starting by working in other's issues and PRs will build a 
degree of familiarity with how the Python development works - what sorts 
of questions get asked, what changes to a PR tend to get asked for, etc.



___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/7TVT56IK54YZOACMD4LYERV3BW23RF7G/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Larry Hastings

On 5/13/21 10:46 AM, Eric V. Smith wrote:

>>> MISSING


I think a repr of just "MISSING", or maybe "dataclasses.MISSING" would 
be better.



I literally just went down this road--for a while there was a special 
sentinel value for the eval_str parameter to inspect.get_annotations().  
The repr I went with was "", e.g "".  It depends on how 
seriously you take the idea that eval(repr(x)) == x.  Certainly most 
objects don't actually support that, e.g., uh, object(), a type which I 
understand is available in most Python implementations.



Cheers,


//arry/

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/FJW37TM7JKZOSZEIYYADJLULT7EH6AJN/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Tal Einat
On Thu, May 13, 2021 at 8:46 PM Eric V. Smith  wrote:
>
>
> On 5/13/2021 1:39 PM, Tal Einat wrote:
> > Here is my suggestion (also posted on the related bpo-44123), which is
> > also simple, ensures a single instance is used, even considering
> > multi-threading and pickling, and has a better repr:
> >
> > class Sentinel:
> >  def __new__(cls, *args, **kwargs):
> >  raise TypeError(f'{cls.__qualname__} cannot be instantiated')
> >
> > class MISSING(Sentinel):
> >  pass
>
>  >>> MISSING
> 
>
> I think a repr of just "MISSING", or maybe "dataclasses.MISSING" would
> be better.

The repr uses whatever module the class is defined in, so we'd get:

>>> from dataclasses import MISSING
>>> MISSING


We could override that to something even cleaner with a meta-class. For example:

class Sentinel(type):
@classmethod
def __prepare__(cls, name, bases, **kwds):
d = super().__prepare__(name, bases, **kwds)
def __new__(cls_, *args, **kwargs):
raise TypeError(f'{cls_!r} is a sentinel and cannot be
instantiated')
d.update(__new__=__new__)
return d

def __repr__(cls):
return f'{cls.__module__}.{cls.__qualname__}'

Which results in:

>>> from dataclasses import MISSING
>>> MISSING
dataclasses.MISSING
>>> type(MISSING)

>>> MISSING()
Traceback (most recent call last): ...
TypeError: dataclasses.MISSING is a sentinel and cannot be instantiated

- Tal


- Tal
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/ECYFQWPBQPRN4ZKDU6WNPPAG3Y5XZ2BD/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Stephen J. Turnbull
Mark Shannon writes:
 > On 13/05/2021 5:32 am, Terry Reedy wrote:

 > > The claim that starts the Motivation section, "Python is widely 
 > > acknowledged as slow.", has multiple problems.

 > How would you rephrase it, bearing in mind that needs to be short?

We can make CPython run significantly faster, at a reasonable cost
in developer time, without otherwise changing the sematics of the
language.

If you have good justification for saying "as fast as the best JS/Lua
implementations" or whatever, feel free to substitute that for
"significantly faster".

And now this:

 > It is a legitimate concern that CPython is bad for the environment,

It is not.

I do this for a living (5 hours in a research hackathon just this
afternoon on a closely related topic[1]), and I assure you that such
"concern" is legitimate only as a matter of purely speculative
metaphysics.  We don't have the data to analyze the possibilities, and
we don't even have the models if we did have the data.

The implied model that gets you from your tautology to "concern" is
just plain wrong -- work to be done is not independent of the cost of
doing it[2], not to mention several other relevant variables, and cannot
be made so in a useful model.

 > and hopefully make it less of a concern.

It is only a concern in the Tucker Carlson "just asking questions"
mode of "concern".  Really -- it's *that* bad.

 > We want people to be able to write code in Python and have it
 > perform at the level they would get from a good Javascript or lua
 > implementation.

So say that.  Nothing to be ashamed of there!

The work you propose to do is valuable for a lot of valid reasons, the
most important of which is "because we can and there's no immediate
downside".[3]  Stick to those.


Footnotes: 
[1] Yoshida, M., Turnbull, S.J. Voluntary provision of environmental
offsets under monopolistic competition. Int Tax Public Finance
(2021). https://doi.org/10.1007/s10797-020-09630-5.
Paywalled, available from the author, rather specialized, though.  Two
works-in-progress are much more closely related, but I have a paranoid
coauthor so can't say more at this time. :-)

[2]  As Steven d'Aprano points out colorfully, using Parkinson's Law.

[3]  Look up Braess's Paradox for a classic and mathematically simple
example of how reducing cost "with no immediate downside" can increase
expense "once everything works itself out."

___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/XK2R7ZUPWTXG4ZDTTE2KB52TFYE6KXEH/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Steven D'Aprano
On Thu, May 13, 2021 at 03:20:31AM -0400, Terry Reedy wrote:

> What is the purpose of this PEP?  It seems in part to be like a 
> Standards Track PEP in that it proposes a new (revised) implementation 
> idea for the CPython bycode interpreter.  Do you not intend this to not 
> constitute approval of even the principle?

Sorry Terry, that last sentence has too many negatives for me to parse 
this early in the morning. Could you rephrase please?


-- 
Steve
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/XL225QYJASK3NXWNIOCXGSY7YNVBC6GZ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: PEP 659: Specializing Adaptive Interpreter

2021-05-13 Thread Steven D'Aprano
On Thu, May 13, 2021 at 08:44:04AM -0700, Christopher Barker wrote:
> I suggest we keep it really simple, and name the implementation.
> 
> Building on Steve Holden’s suggestion:
> 
> There is broad interest in improving the performance of the cPython
> runtime. (Interpreter?)

+1

As excellent as Mark's work will undoubtfully be, I will be surprised if 
it will result in PyPy, MicroPython, Nuitka, etc becoming faster too :-)


-- 
Steve
(one of the other ones)
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/4HUXRVTXYNTVEC46QAX7ELVWF6Y4Q6MT/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread Christopher Barker
There was a discussion a while back ( a year or so?? ) on Python-ideas that
introduced the idea of having more "sentinel-like" singletons in Python --
right now, we only have None.

I can't remember the context, but the consensus seemed to be that it
was easy to create a custom sentinel object, and it was not worth adding
more "official" ones to the language. But this conversation reminded me
about that, and while I do agree that we don't need more that are elevated
to the status of None, maybe it would be good to have a couple (or only
MISSING) in the standard library somewhere "central" for everyone to use.
"central" rather than in, say, dataclasses.

I'm not sure where that should be, the operator module, maybe??

Ayway, if someone were to put one of the nifty implementations being
discussed here in the stdlib --I'd use it :-)

-CHB




On Thu, May 13, 2021 at 1:14 PM Tal Einat  wrote:

> On Thu, May 13, 2021 at 8:46 PM Eric V. Smith  wrote:
> >
> >
> > On 5/13/2021 1:39 PM, Tal Einat wrote:
> > > Here is my suggestion (also posted on the related bpo-44123), which is
> > > also simple, ensures a single instance is used, even considering
> > > multi-threading and pickling, and has a better repr:
> > >
> > > class Sentinel:
> > >  def __new__(cls, *args, **kwargs):
> > >  raise TypeError(f'{cls.__qualname__} cannot be instantiated')
> > >
> > > class MISSING(Sentinel):
> > >  pass
> >
> >  >>> MISSING
> > 
> >
> > I think a repr of just "MISSING", or maybe "dataclasses.MISSING" would
> > be better.
>
> The repr uses whatever module the class is defined in, so we'd get:
>
> >>> from dataclasses import MISSING
> >>> MISSING
> 
>
> We could override that to something even cleaner with a meta-class. For
> example:
>
> class Sentinel(type):
> @classmethod
> def __prepare__(cls, name, bases, **kwds):
> d = super().__prepare__(name, bases, **kwds)
> def __new__(cls_, *args, **kwargs):
> raise TypeError(f'{cls_!r} is a sentinel and cannot be
> instantiated')
> d.update(__new__=__new__)
> return d
>
> def __repr__(cls):
> return f'{cls.__module__}.{cls.__qualname__}'
>
> Which results in:
>
> >>> from dataclasses import MISSING
> >>> MISSING
> dataclasses.MISSING
> >>> type(MISSING)
> 
> >>> MISSING()
> Traceback (most recent call last): ...
> TypeError: dataclasses.MISSING is a sentinel and cannot be instantiated
>
> - Tal
>
>
> - Tal
> ___
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/ECYFQWPBQPRN4ZKDU6WNPPAG3Y5XZ2BD/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/BMO6NXKJ37LIFQDBOBASEAWWDDAPWTYX/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread David Mertz
On Thu, May 13, 2021 at 10:31 PM Christopher Barker 
wrote:

> There was a discussion a while back ( a year or so?? ) on Python-ideas
> that introduced the idea of having more "sentinel-like" singletons in
> Python -- right now, we only have None.
>

As I remember, the year-ago conversation was basically wanting more ways of
saying "argument not specified" in function signatures.  The thought was
that None is used pretty often to mean something somewhat different.  The
rough consensus seemed to be that `my_sentinel = object()` was a low burden
per project.

But in what I recall, there was no talk there of custom behavior like a
nicer repr().  My own feeling is that ONLY a repr() isn't quite enough to
motivate an addition to stdlib.  But if there were a few other useful
behaviors, maybe it would be (e.g. maybe default or specifiable inequality
operations).  However, I wouldn't really want another two or three or four
singletons, but rather a slightly more templated factory than just
`object()`.

-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/YGUSXTZ3W35G55TQ37F7AAICFX54JAOR/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] Re: The repr of a sentinel

2021-05-13 Thread micro codery
> There was a discussion a while back ( a year or so?? ) on Python-ideas
> that introduced the idea of having more "sentinel-like" singletons in
> Python -- right now, we only have None.
>

Not quite true, we also have Ellipsis, which already has a nice repr that
both reads easily and still follows the convention of eval(repr(x)) == x.
It also is already safe from instantiation, survives pickle round-trip and
is multi-thread safe.
So long as you are not dealing with scientific projects, it seems a
quick (if dirty) solution to having a sentinel that is not None. There is
also some symmetrical wholeness when considered with the other builtin
sentinels: bool(None) is False; bool(Ellipsis) is True.
___
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/UQPD5NNAVWIQWIACOY7YRZGWMJO4URJ5/
Code of Conduct: http://python.org/psf/codeofconduct/