Re: Does loading PDB slow down execution?
Unixnut wrote at 2021-10-3 22:03 +0100: >If I run a python3 program with "import pdb" in the code, would it >execute slower than without loading the debugger? Importing `pdb` does not slow down the application significantly (it just adds the import time but does not otherwise affect the application). Only when you execute code under debugger control, the execution is significantly slowed down (because the debugger gets informed (via callbacks) about important "event"s (entering a line, function call, function return, exception) during the execution). -- https://mail.python.org/mailman/listinfo/python-list
Re: matplotlib graph white space
On 04/10/2021 10:39, Steve wrote: I am using the first bar graph listed at this site: https://matplotlib.org/stable/gallery/index.html The problem I have is that there is too much white space around the graph. My data would be better displayed if I could widen the graph into the space to the right and left of the chart. Steve To tweak the amount of padding around the matplotlib axes, you can use pyplot.subplots_adjust [1] or Figure.subplots_adjust [2]. In most cases, the tight_layout function/method [3,4] will give you sensible settings for the various spacing parameters. You probably also have to adjust the figure size (see David Lowry-Duda's reply) to get whatever effect it is that you want. [1] https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots_adjust.html [2] https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.subplots_adjust [3] https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.tight_layout.html [4] https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.tight_layout -- https://mail.python.org/mailman/listinfo/python-list
Re: Confusing error message: lambda walruses
On 03/10/2021 01:39, Chris Angelico wrote: Using assignment expressions in lambda functions sometimes works, but sometimes doesn't. Does this commit by a certain Chris Angelico help clear things up? https://github.com/python/peps/commit/f906b988b20c9a8e7e13a2262f5381bd2b1399e2 -- https://mail.python.org/mailman/listinfo/python-list
Re: Confusing error message: lambda walruses
On Thu, Oct 7, 2021 at 8:51 AM Thomas Jollans wrote: > > On 03/10/2021 01:39, Chris Angelico wrote: > > Using assignment expressions in lambda functions sometimes works, but > > sometimes doesn't. > > Does this commit by a certain Chris Angelico help clear things up? > > https://github.com/python/peps/commit/f906b988b20c9a8e7e13a2262f5381bd2b1399e2 No, because the examples I gave don't fit into that :) I was aware of what the PEP originally said. If you try to align the examples with the descriptions in the PEP, you'll find that they don't all match. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Confusing error message: lambda walruses
On 06/10/2021 23:53, Chris Angelico wrote: On Thu, Oct 7, 2021 at 8:51 AM Thomas Jollans wrote: On 03/10/2021 01:39, Chris Angelico wrote: Using assignment expressions in lambda functions sometimes works, but sometimes doesn't. Does this commit by a certain Chris Angelico help clear things up? https://github.com/python/peps/commit/f906b988b20c9a8e7e13a2262f5381bd2b1399e2 No, because the examples I gave don't fit into that :) I was aware of what the PEP originally said. If you try to align the examples with the descriptions in the PEP, you'll find that they don't all match. ChrisA The issue closed by that commit is interesting, if nothing else: Guido van Rossum wrote: The PEP says very little about lambda. I feel the following two examples should both be valid: foo(f := lambda: 42, flag=True) foo(lambda: f := 42, flag=True) Chris Angelico wrote: The second example is kinda bizarre though; it's going to create a fairly useless name binding within the lambda function. (Unless you want to give lambda functions the same magic as comprehensions, making the name f exist in the same scope where foo is being run.) So I would be okay with the first example doing the obvious thing, and the second one requiring parentheses lambda: (f := 42) for syntactic validity. I think that at least clears up this part: # But a SyntaxError if parenthesized like this?? def f(n): ... return (lambda: n := 1) File "", line 2 return (lambda: n := 1) ^ SyntaxError: cannot use assignment expressions with lambda # Oh, and it doesn't actually assign anything. def f(n): ... return (lambda: (n := 1)), (lambda: n) ... -- https://mail.python.org/mailman/listinfo/python-list
