Type Hint Support, MetaData, Syntactic Sugar
Pre-release
Pre-release
Lots of big features. This should be backwards compatible, but there are major upgrades. Hence the change in version number.
New Features:
- It is possible to properly type-hint so that a good editor will be able to understand typing in
func_adl
queries. This makes heavy use of python'sGeneric
type as we are often working with streams of objects (like events or jets, etc.). - Python list comprehensions and generator expressions inside
lambda
's are now converted tofunc_adl
automatically. Ifs and multiple generators are supported. - Variables referenced inside lambda expressions are now properly captured. So you can parameterize a cut some external variables. Method and attribute and function calls on captured variables are not supported.
New Extensibility Points
- Parameterized method calls are supported. You can write something like
[j.getAttribute[cpp_float]('EMF') for j in jets]
and with the proper support it will generate a C++ template function. Thefunc_adl
library provides none of the support, but you can use the decoratorfunc_adl_parameterized_call
- You can now use the
@func_adl_callback
decorator to decorate a class or a method in your type hints file to invoke custom python code as the query is built. This allows extensions, default argument processing, etc. The C++ xAOD backend heavily uses this to implement things like calibration, etc. - Query Metadata can be attached to an expression. It is stripped out before being sent down to ServiceX. This can be used to cache information that needs to be tracked in a query. The C++ xAOD type system uses this to track calibration configuration.
- MetaData can be sent down to the backend at arbitrary points in the query. This can be used, for example, to declare types to the C++ backend.
Technical Debt:
- Numerous clean ups to the type hinting in the library
- Test coverage improvements, which uncovered some python version incompatibilities (which were fixed).
- Using
black
as the formatted for the repo - README documentation improvements
- Supporting 3.7 is getting to be work. Python 3.10 is supported.
- Added full support for the type
bool
.