[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-29 Thread Malthe
On Fri, 29 Apr 2022 at 06:50, Thomas Grainger wrote: > You can use a `__del__` method that warns on collection - like an unawaited > coroutine > > Also if you're in control of importing the dagfile you can record all created > dags and report any that are missing from the globals of the module

[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
On Fri, 29 Apr 2022 at 06:38, Thomas Grainger wrote: > Can you show a run-able example of the successful and unsuccessful usage of > `with DAG(): ... `? from airflow import DAG # correct: dag = DAG("my_dag") # incorrect: DAG("my_dag") The with construct really has nothing to do with it, but i

[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Pablo Galindo Salgado wrote: > As it has been mentioned there is no guarantee that your variable will even > be finalized (or even destroyed) after the frame finishes. For example, if > your variable goes into a reference cycle for whatever reason it may not be > cleared until a GC run happens (and

[Python-Dev] Re: Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Dennis Sweeney wrote: > I don't know if there's anything specifically stopping this, but from what I > understand, the precise moment that a finalizer gets called is unspecified, > so relying on any sort of behavior there is undefined and non-portable. > Implementations like PyPy don't always us

[Python-Dev] Decreasing refcount for locals before popping frame

2022-04-28 Thread Malthe
Consider this example code: def test(): a = A() test() Currently, the locals (i.e. `a`) are cleared only after the function has returned: If we attach a finalizer to `a` immediately after the declaration then the frame stack available via `sys._getframe()` inside the finalizer function does

[Python-Dev] Re: Declarative imports

2022-04-10 Thread Malthe
On Sun, 10 Apr 2022 at 09:31, Daniel Pope wrote: > I would like to bid again for (import package.module) as an expression. > Instead of doing the import and assigning package to a variable package it > would evaluate to the module object package.module. I like this proposal and I agree with pre

[Python-Dev] Re: Declarative imports

2022-04-08 Thread Malthe
On Fri, 8 Apr 2022 at 16:40, Guido van Rossum wrote: > The interesting idea here seems to make "lazy imports" easier to implement by > making them explicit in the code. So far, most lazy import frameworks for > Python have done hacks with `__getattribute__` overrides. IIRC the Cinder > version

[Python-Dev] Re: Declarative imports

2022-04-08 Thread Malthe
On Fri, 8 Apr 2022 at 10:15, Daniel Pope wrote: > But, your proposed syntax is not usable because it is ambiguous. Exactly what > you propose is already used for decorators in a way that the parser would not > be able to distinguish a decorator from an import expression. Consider: > > @ham.s

[Python-Dev] Re: Declarative imports

2022-04-08 Thread Malthe
On Fri, 8 Apr 2022 at 08:51, Paul Moore wrote: > Are you exaggerating for effect here or would this *actually* just expand to > > from datetime import datetime > default_args = { > "start_date": datetime(...) > } Yes – and of course that is just a snippet, an actual complete script will have

[Python-Dev] Declarative imports

2022-04-08 Thread Malthe
This is an idea which has been brought up before, sometimes introduced as "heresy". But an interesting twist has surfaced now which is typing. But firstly, let me present the idea. It is very simple, that Python should have declarative imports, usable anywhere using a simple syntax, @. For exampl

Re: [Python-Dev] Proposing PEP 386 for addition

2009-12-10 Thread Malthe Borch
2009/12/10 Darren Dale : > Those aren't new proposals, though, they already exist in distutils. I see. Thanks for clarifying –– maybe the PEP should better explain this. \malthe ___ Python-Dev mailing list Python-Dev@python.org http://mail.py

Re: [Python-Dev] Proposing PEP 386 for addition

2009-12-10 Thread Malthe Borch
alVersion`` and ``ChronologicalVersion`` (or ``NumberedVersion``). It's not about strictness or looseness. Also, the word "rational" is not familiar to me in the context of versions; is this term known outside of this proposal? I couldn't f

[Python-Dev] Transformation with ``parser`` ast

2008-10-13 Thread Malthe Borch
limitations, however, I could not find a transformer class compatible with its tree structure. What's the recommended way of working with the AST tree from the ``parser`` module? \malthe ___ Python-Dev mailing list Python-Dev@python.org http:

Re: [Python-Dev] Syntax error in python2.6

2008-07-21 Thread Malthe Borch
Lennart Regebro wrote: 2. Using **kw in the argument and looking for noth "with" and "with_", that way, which will be backwards compatible. +1 \malthe ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mai