[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-10 Thread Antoine Pitrou
On Thu, 9 Apr 2020 20:56:56 -0700 "Gregory P. Smith" wrote: > On Wed, Apr 8, 2020, 10:37 AM Antoine Pitrou wrote: > > > On Wed, 8 Apr 2020 10:18:47 -0700 > > Guido van Rossum wrote: > > > > > > > But when I leave "large" temp objects hanging and > > > > give a rip, I already stick in

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Gregory P. Smith
On Wed, Apr 8, 2020, 10:37 AM Antoine Pitrou wrote: > On Wed, 8 Apr 2020 10:18:47 -0700 > Guido van Rossum wrote: > > > > > But when I leave "large" temp objects hanging and > > > give a rip, I already stick in "del" statements anyway. Very rarely, > > > but it happens. > > > > > > > I recall

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Andrew Barnert via Python-ideas
On Apr 9, 2020, at 15:13, Wes Turner wrote: > > - > And then take a look at how @ApacheArrow > "supports zero-copy reads for lightning-fast data access without > serialization overhead." > - .@blazingsql … #cuDF … @ApacheArrow > https://docs.blazingdb.com/docs/blazingsql This isn’t

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Wes Turner
Thanks for removing the mystery. FWIW, here are some of the docs and resources for memory management in Python; I share these not to be obnoxious or to atoen, but to point to the docs that would need updating to explain what is going on if this is not explicit. -

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Andrew Barnert via Python-ideas
On Apr 8, 2020, at 23:53, Wes Turner wrote: > > Could something just heuristically add del statements with an AST > transformation that we could review with source control before committing? > > When the gc pause occurs is something I don't fully understand. For example: Your examples don’t

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Tolo Palmer
What about nested functions? I am not sure how we can predict if that variable is going to be used or not. I think this is a nice idea to have such an analysis, but I don't think is feasible. On Thu, 9 Apr 2020 at 04:29, Caleb Donovick wrote: > This would almost certainly break my code. As a

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-09 Thread Wes Turner
Could something just heuristically add del statements with an AST transformation that we could review with source control before committing? When the gc pause occurs is something I don't fully understand. For example: FWIW, this segfaults CPython in 2 lines: import ctypes ctypes.cast(1,

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Caleb Donovick
This would almost certainly break my code. As a DSL developer I do a lot of (exec | eval | introspection | ... ) shenanigans, that would make doing liveness analysis undecidable. On Wed, Apr 8, 2020 at 10:51 AM Andrew Barnert via Python-ideas < python-ideas@python.org> wrote: > On Apr 8, 2020,

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Andrew Barnert via Python-ideas
On Apr 8, 2020, at 09:57, Guido van Rossum wrote: > >  > Look at the following code. > > def foo(a, b): > x = a + b > if not x: > return None > sleep(1) # A calculation that does not use x > return a*b > > This code DECREFs x when the frame is exited (at the return

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Brett Cannon
On Wed, Apr 8, 2020 at 10:23 AM Guido van Rossum wrote: > On Wed, Apr 8, 2020 at 10:05 AM Alex Hall wrote: > >> This would break uses of locals(), e.g. >> > > Hm, okay, so suppose the code analysis was good enough to recognize most > un-obfuscated uses of locals(), exec() and eval() (and

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Gregory P. Smith
On Wed, Apr 8, 2020 at 10:21 AM Guido van Rossum wrote: > On Wed, Apr 8, 2020 at 10:05 AM Alex Hall wrote: > >> This would break uses of locals(), e.g. >> > > Hm, okay, so suppose the code analysis was good enough to recognize most > un-obfuscated uses of locals(), exec() and eval() (and

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Antoine Pitrou
On Wed, 8 Apr 2020 10:18:47 -0700 Guido van Rossum wrote: > > > But when I leave "large" temp objects hanging and > > give a rip, I already stick in "del" statements anyway. Very rarely, > > but it happens. > > > > I recall that in the development of asyncio there were a few places where >

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Guido van Rossum
On Wed, Apr 8, 2020 at 10:13 AM Tim Peters wrote: > My guess: it would overwhelmingly free tiny objects, giving a > literally unmeasurable (just theoretically provable) memory savings, > at the cost of adding extra trips around the eval loop. So not really > attractive to me. Yeah, the extra

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread MRAB
On 2020-04-08 17:53, Guido van Rossum wrote: Look at the following code. def foo(a, b):     x = a + b     if not x:     return None     sleep(1)  # A calculation that does not use x     return a*b This code DECREFs x when the frame is exited (at the return statement). But (assuming)

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Guido van Rossum
On Wed, Apr 8, 2020 at 10:05 AM Alex Hall wrote: > This would break uses of locals(), e.g. > Hm, okay, so suppose the code analysis was good enough to recognize most un-obfuscated uses of locals(), exec() and eval() (and presumably sys._getframe() -- IIUC there's already a Python implementation

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Antoine Pitrou
On Wed, 8 Apr 2020 09:53:41 -0700 Guido van Rossum wrote: > Look at the following code. > > def foo(a, b): > x = a + b > if not x: > return None > sleep(1) # A calculation that does not use x > return a*b > > This code DECREFs x when the frame is exited (at the return

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Tim Peters
[Guido] > Look at the following code. > > def foo(a, b): > x = a + b > if not x: > return None > sleep(1) # A calculation that does not use x > return a*b > > This code DECREFs x when the frame is exited (at the return statement). > But (assuming) we can clearly see that x

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Alex Hall
This would break uses of locals(), e.g. def foo(a, b): x = a + b if not x: return None del x print('{x}, {a}, {b}'.format(**locals())) return a * b foo(1, 2) Plus if the calculation raises an exception and I'm looking at the report on Sentry, I'd like to see the

[Python-ideas] Re: Live variable analysis -> earlier release?

2020-04-08 Thread Brandt Bucher
> Can anyone tear this idea apart? `exec` and `eval` come to mind... I'm sure there are also nasty `inspect` hacks this could break, too? def foo(a, b): x = a + b if not x: return None sleep(1) # A calculation that does not use x return eval("x")