egglog 10.0.2__cp312-cp312-win_amd64.whl → 11.1.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of egglog might be problematic. Click here for more details.
- egglog/__init__.py +3 -1
- egglog/bindings.cp312-win_amd64.pyd +0 -0
- egglog/bindings.pyi +26 -34
- egglog/builtins.py +231 -183
- egglog/conversion.py +61 -43
- egglog/declarations.py +103 -17
- egglog/deconstruct.py +173 -0
- egglog/egraph.py +78 -130
- egglog/egraph_state.py +17 -14
- egglog/examples/bignum.py +1 -1
- egglog/examples/multiset.py +2 -2
- egglog/exp/array_api.py +37 -3
- egglog/exp/array_api_jit.py +11 -5
- egglog/exp/array_api_program_gen.py +1 -1
- egglog/exp/program_gen.py +2 -2
- egglog/pretty.py +11 -25
- egglog/runtime.py +197 -147
- egglog/version_compat.py +3 -3
- {egglog-10.0.2.dist-info → egglog-11.1.0.dist-info}/METADATA +1 -1
- {egglog-10.0.2.dist-info → egglog-11.1.0.dist-info}/RECORD +22 -22
- {egglog-10.0.2.dist-info → egglog-11.1.0.dist-info}/WHEEL +1 -1
- egglog/functionalize.py +0 -91
- {egglog-10.0.2.dist-info → egglog-11.1.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
egglog-
|
|
2
|
-
egglog-
|
|
3
|
-
egglog-
|
|
4
|
-
egglog/__init__.py,sha256=
|
|
5
|
-
egglog/bindings.cp312-win_amd64.pyd,sha256=
|
|
6
|
-
egglog/bindings.pyi,sha256
|
|
7
|
-
egglog/builtins.py,sha256=
|
|
1
|
+
egglog-11.1.0.dist-info/METADATA,sha256=865-TFtrwCy1OfpeqBU2BcK96tl3G4hG1AMb4fVNCZU,4019
|
|
2
|
+
egglog-11.1.0.dist-info/WHEEL,sha256=HF3aUMilrtO42xS_fBzOVaPE8OtiNjP_RotLatII7HM,96
|
|
3
|
+
egglog-11.1.0.dist-info/licenses/LICENSE,sha256=TfaboMVZ81Q6OUaKjU7z6uVjSlcGKclLYcOpgDbm9_s,1091
|
|
4
|
+
egglog/__init__.py,sha256=CAD9lfaUAcqSoTtprQfsFYqoOcqxAYsGBDU7laaYj0w,357
|
|
5
|
+
egglog/bindings.cp312-win_amd64.pyd,sha256=RBang7LLIidBOyvOFYKpCJ_QqgisOXyB0FzjsFkR5bE,10308096
|
|
6
|
+
egglog/bindings.pyi,sha256=-sm1qF7dDGEsFGDbny8LEIYTFMnlDfUV7HfQ-P81Crg,14301
|
|
7
|
+
egglog/builtins.py,sha256=StODsE0YzfDmRnvt3lJChwUa9TQ-M16EAGQMjVS2njI,31337
|
|
8
8
|
egglog/config.py,sha256=mALVaxh7zmGrbuyzaVKVmYKcu1lF703QsKJw8AF7gSM,176
|
|
9
|
-
egglog/conversion.py,sha256=
|
|
10
|
-
egglog/declarations.py,sha256=
|
|
11
|
-
egglog/
|
|
12
|
-
egglog/
|
|
9
|
+
egglog/conversion.py,sha256=YSkLn744-Ci_GmlcZAvLwmJNN8WZyYDjPI8Sqj5TN-0,11524
|
|
10
|
+
egglog/declarations.py,sha256=nXO13l2s8K-PB2d4ARoIS63deuxo0RWG9zAFKG3APBA,26688
|
|
11
|
+
egglog/deconstruct.py,sha256=BzcrC1Qc_hlFhfQ2kkh1JB9Ur9Vi6IyjqM6KLhrZR58,5808
|
|
12
|
+
egglog/egraph.py,sha256=aI0POepFzToRW8-OZIlMY-ELinK3DvB3clBbxvPit-s,62400
|
|
13
|
+
egglog/egraph_state.py,sha256=hdjM10qpeeUypNM7OREPT9uxVD0kvn6WaoMkXq96TpU,28993
|
|
13
14
|
egglog/examples/README.rst,sha256=QrbfmivODBvUvmY3-dHarcbC6bEvwoqAfTDhiI-aJxU,237
|
|
14
15
|
egglog/examples/__init__.py,sha256=KuhaJFOyz_rpUvEqZubsgLnv6rhQNE_AVFXA6bUnpdY,34
|
|
15
|
-
egglog/examples/bignum.py,sha256=
|
|
16
|
+
egglog/examples/bignum.py,sha256=KSt7V__O8IFbfvjkwOwJ5Dnw2JUFnYSyEfhfu8M71YY,567
|
|
16
17
|
egglog/examples/bool.py,sha256=pWZTjfXR1cFy3KcihLBU5AF5rn83ImORlhUUJ1YiAXc,733
|
|
17
18
|
egglog/examples/eqsat_basic.py,sha256=ivYHFD52sjYyl5rWQ60ScxmvcbABYUBlPobDMu6HvN4,913
|
|
18
19
|
egglog/examples/fib.py,sha256=wAn-PjazxgHDkXAU4o2xTk_GtM_iGL0biV66vWM1st4,520
|
|
19
20
|
egglog/examples/higher_order_functions.py,sha256=z8HgCi057k7Rt6Ms4xDz_tsmVj_Czx8JMUSWqd0HlvM,1105
|
|
20
21
|
egglog/examples/lambda_.py,sha256=y0HrgtmF2Ml2h2crRvqd1fYRtJGPP_n91o-fiWfyCLM,8481
|
|
21
22
|
egglog/examples/matrix.py,sha256=_zmjgfFr2O_LjTcsTD-45_38Y_M1sP3AV39K6oFxAdw,5136
|
|
22
|
-
egglog/examples/multiset.py,sha256=
|
|
23
|
+
egglog/examples/multiset.py,sha256=uAy7RZRzU2OBeNp0R4xWxZmF7NXDFGRr_dIbH26tUsY,1505
|
|
23
24
|
egglog/examples/ndarrays.py,sha256=T-wwef-n-3LDSjaO35zA8AZH5DXFFqq0XBSCQKEXV6E,4186
|
|
24
25
|
egglog/examples/resolution.py,sha256=sKkbRI_v9XkQM0DriacKLINqKKDqYGFhvMCAS9tZbTA,2203
|
|
25
26
|
egglog/examples/schedule_demo.py,sha256=iJtIbcLaZ7zK8UalY0z7KAKMqYjQx0MKTsNF24lKtik,652
|
|
26
27
|
egglog/exp/__init__.py,sha256=G9zeKUcPBgIhgUg1meC86OfZVFETYIugyHWseTcCe_0,52
|
|
27
|
-
egglog/exp/array_api.py,sha256=
|
|
28
|
-
egglog/exp/array_api_jit.py,sha256=
|
|
28
|
+
egglog/exp/array_api.py,sha256=3f_lh6vI-vvxlKW3ocV8FT3FH4TQ1VqSAB6vZEnF0Fk,67567
|
|
29
|
+
egglog/exp/array_api_jit.py,sha256=1mp6s2e2ySqulfb5pFuTQZ-IQ3UdDmT7eJvJME1X5hs,1731
|
|
29
30
|
egglog/exp/array_api_loopnest.py,sha256=1KZ8kWtv00TVCbzqzWG92vz8Y1pBlPOLRIrJfxyDs9s,2518
|
|
30
31
|
egglog/exp/array_api_numba.py,sha256=g0Yb7auB2MtJHgSzn7iVnsxn6ffL4FHggKvbEuuDwZs,2765
|
|
31
|
-
egglog/exp/array_api_program_gen.py,sha256=
|
|
32
|
-
egglog/exp/program_gen.py,sha256=
|
|
32
|
+
egglog/exp/array_api_program_gen.py,sha256=LatOqKiGVzpUhWIGtoZw9lLZdK3Oeg7XjR4ILLGby10,22289
|
|
33
|
+
egglog/exp/program_gen.py,sha256=CiLgPo2YoQi83DAVmR7gU61ocWkxnYEV1toie8y8ppQ,13458
|
|
33
34
|
egglog/exp/siu_examples.py,sha256=nPV1IaA2NfIczpJPg3l8diUhoyio02KQUu-O55Pj1EQ,751
|
|
34
|
-
egglog/functionalize.py,sha256=7yBi5rlYS56lP4Fz_2REyOyj56Tag5R80bXkUXfj5pk,3938
|
|
35
35
|
egglog/ipython_magic.py,sha256=QDw45CA2wKi9vrBbvHZXLeMaRtoHSGLBJdqyNFtvD7o,1230
|
|
36
|
-
egglog/pretty.py,sha256=
|
|
36
|
+
egglog/pretty.py,sha256=pSTOMAgywLZ_0Y3oxYPmIbtxsVADWFw60G3LKTOYFWk,20632
|
|
37
37
|
egglog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
-
egglog/runtime.py,sha256=
|
|
38
|
+
egglog/runtime.py,sha256=pOuAnqK_5Fb3Q0tfjC0JUIPoi9eEQtQBg38TtmnNSUQ,28664
|
|
39
39
|
egglog/thunk.py,sha256=97JH5VVrr5m3yaua40StfDsQYEvACXirBzZv9CHHLbY,2368
|
|
40
40
|
egglog/type_constraint_solver.py,sha256=uRLho3KQUtMn3ncugXADN5SfNqmqekduOl5CuWhhx4M,4631
|
|
41
|
-
egglog/version_compat.py,sha256=
|
|
41
|
+
egglog/version_compat.py,sha256=QGgZo85mwGsuFqNkRfLiGdxGR0K-B5Pax0f7fRjMW50,3599
|
|
42
42
|
egglog/visualizer.css,sha256=DDmxZfLmFygwVkQwel0gGUiM5BZqgunawWeSfaRYBr8,259399
|
|
43
43
|
egglog/visualizer.js,sha256=kDkYzE5cLLhmpNaWqSfQWzD0SlSsNe9KzT_GpNqhWgo,3789092
|
|
44
44
|
egglog/visualizer_widget.py,sha256=TGkf61P_f4EvCFcyqwQC_8XYUkujFhcQnEG9vHWLPC4,1358
|
|
45
|
-
egglog-
|
|
45
|
+
egglog-11.1.0.dist-info/RECORD,,
|
egglog/functionalize.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from collections.abc import Callable
|
|
4
|
-
from functools import partial
|
|
5
|
-
from inspect import Parameter, signature
|
|
6
|
-
from typing import Any, TypeVar, cast
|
|
7
|
-
|
|
8
|
-
__all__ = ["functionalize"]
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
T = TypeVar("T", bound=Callable)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# TODO: Add `to_lift` param so that we only transform those with vars in them to args
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def functionalize(f: T, get_annotation: Callable[[object], type | None]) -> T:
|
|
18
|
-
"""
|
|
19
|
-
Takes a function and returns a new function with all names (co_names) and free variables (co_freevars) added as arguments
|
|
20
|
-
and then partially applied with their values. The second arg, get_annotation, will be applied to all values
|
|
21
|
-
to get their type annotation. If it is None, that arg will not be added as a parameter.
|
|
22
|
-
|
|
23
|
-
For example if you have:
|
|
24
|
-
|
|
25
|
-
def get_annotation(x): return int if x <= 10 else None
|
|
26
|
-
|
|
27
|
-
g = 10
|
|
28
|
-
def f(a, a2):
|
|
29
|
-
def h(b: Z):
|
|
30
|
-
return a + a2 + b + g
|
|
31
|
-
|
|
32
|
-
return functionalize(h, get_annotation)
|
|
33
|
-
res = f(9, 11)
|
|
34
|
-
|
|
35
|
-
It should be equivalent to (according to body, signature, and annotations) (Note that the new arguments will be positional only):
|
|
36
|
-
|
|
37
|
-
def h(a: get_annotation(a), g: get_annotation(g), b: Z):
|
|
38
|
-
return a + b + g
|
|
39
|
-
res = partial(h, a, g)
|
|
40
|
-
"""
|
|
41
|
-
code = f.__code__
|
|
42
|
-
names = tuple(n for n in code.co_names if n in f.__globals__)
|
|
43
|
-
free_vars = code.co_freevars
|
|
44
|
-
|
|
45
|
-
global_values: list[Any] = [f.__globals__[name] for name in names]
|
|
46
|
-
free_var_values = [cell.cell_contents for cell in f.__closure__] if f.__closure__ else []
|
|
47
|
-
assert len(free_var_values) == len(free_vars), "Free vars and their values do not match"
|
|
48
|
-
global_values_filtered = [
|
|
49
|
-
(i, name, value, annotation)
|
|
50
|
-
for i, (name, value) in enumerate(zip(names, global_values, strict=True))
|
|
51
|
-
if (annotation := get_annotation(value)) is not None
|
|
52
|
-
]
|
|
53
|
-
free_var_values_filtered = [
|
|
54
|
-
(i, name, value, annotation)
|
|
55
|
-
for i, (name, value) in enumerate(zip(free_vars, free_var_values, strict=True))
|
|
56
|
-
if (annotation := get_annotation(value)) is not None
|
|
57
|
-
]
|
|
58
|
-
additional_arg_filtered = global_values_filtered + free_var_values_filtered
|
|
59
|
-
|
|
60
|
-
# Create a wrapper function
|
|
61
|
-
def wrapper(*args):
|
|
62
|
-
# Split args into names, free vars and other args
|
|
63
|
-
name_args, free_var_args, rest_args = (
|
|
64
|
-
args[: (n_names := len(global_values_filtered))],
|
|
65
|
-
args[n_names : (n_args := len(additional_arg_filtered))],
|
|
66
|
-
args[n_args:],
|
|
67
|
-
)
|
|
68
|
-
# Update globals with names
|
|
69
|
-
f.__globals__.update({
|
|
70
|
-
name: arg for (_, name, _, _), arg in zip(global_values_filtered, name_args, strict=False)
|
|
71
|
-
})
|
|
72
|
-
# update function free vars with free var args
|
|
73
|
-
for (i, _, _, _), value in zip(free_var_values_filtered, free_var_args, strict=True):
|
|
74
|
-
assert f.__closure__, "Function does not have closure"
|
|
75
|
-
f.__closure__[i].cell_contents = value
|
|
76
|
-
return f(*rest_args)
|
|
77
|
-
|
|
78
|
-
# Set the signature of the new function to a signature with the free vars and names added as arguments
|
|
79
|
-
orig_signature = signature(f)
|
|
80
|
-
wrapper.__signature__ = orig_signature.replace( # type: ignore[attr-defined]
|
|
81
|
-
parameters=[
|
|
82
|
-
*[Parameter(n, Parameter.POSITIONAL_OR_KEYWORD) for _, n, _, _ in additional_arg_filtered],
|
|
83
|
-
*orig_signature.parameters.values(),
|
|
84
|
-
]
|
|
85
|
-
)
|
|
86
|
-
# Set the annotations of the new function to the annotations of the original function + annotations of passed in values
|
|
87
|
-
wrapper.__annotations__ = f.__annotations__ | {n: a for _, n, _, a in additional_arg_filtered}
|
|
88
|
-
wrapper.__name__ = f.__name__
|
|
89
|
-
|
|
90
|
-
# Partially apply the wrapper function with the current values of the free vars
|
|
91
|
-
return cast("T", partial(wrapper, *(v for _, _, v, _ in additional_arg_filtered)))
|
|
File without changes
|