Replies: 3 comments 5 replies
-
|
The examples look good. It is not clear to me what the impact of this would be on the ability to produce separately compiled guppy modules. Does a single |
Beta Was this translation helpful? Give feedback.
-
|
A bit of a secondary concern, but just thinking of modules in the context of language services, specifically the difference between wanting to say run |
Beta Was this translation helpful? Give feedback.
-
|
Completed with #983 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal
Get rid of the user-facing
GuppyModuleand only use module-free@guppydecorators. Things should just behave like Python:main.compile()instead ofmodule.compile())module.unregister(...). If a faulty function is not used, it's not going to be compiledExamples
Python style late binding
Similarly, as in Python, it's fine to import late
Functions can be dynamically created:
How to do it (draft)
For each invocation of the guppy decorator:
capturedf_localsof the frame in which the function was defined. Any mutation of captured Python variables after the function was defined will be visible throughf_locals!Get rid of
guppy.compile_module. Instead, offer.check()and.compile()methods on all guppy decorated objects. When calling those, do the following:capturednames and looking them up in the correspondingf_localsand__globals__(in that order). If they contain any guppy definitions, mark them as dependencies and proceed recursively.capturedto store the actual values for easy lookup later without having to look again intof_locals. This also means, we can dropf_localsto get rid of some reference cycles and help the GCWhen type checking a function body:
captured, load the value. Otherwise, check if it's a previously defined local, else emit a user error.expr.name, we check ifexpris a captured Python module. In that case, we'll try to look upnamefrom that moduleNotes:
__closure__would not be enough since it doesn't contain values captured in the type signature. That's why we have to store the entiref_localsdict. However, this might change with Python 3.14 annotation descriptors: https://peps.python.org/pep-0649/Beta Was this translation helpful? Give feedback.
All reactions