You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a pyccel.lambdify function with similar functionality to sympy.lambdify (pyccel#1829)
Given a SymPy expression `f` and type annotations, `lambdify` returns
a "pyccelised" function `f_fast` that can be used in the same Python
session. Fixespyccel#1827.
Copy file name to clipboardExpand all lines: .github/actions/pytest_run/action.yml
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ runs:
28
28
shell: ${{ inputs.shell_cmd }}
29
29
working-directory: ./tests
30
30
- name: Test C translation
31
-
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and c ${{ inputs.pytest_mark }}" --ignore=symbolic --ignore=ndarrays 2>&1 | tee s1_outfile.out
31
+
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and c ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s1_outfile.out
32
32
shell: ${{ inputs.shell_cmd }}
33
33
working-directory: ./tests
34
34
id: pytest_1
@@ -45,19 +45,19 @@ runs:
45
45
id: pytest_2
46
46
- name: Test multi-file C translations
47
47
run: |
48
-
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and c ${{ inputs.pytest_mark }}" --ignore=symbolic --ignore=ndarrays 2>&1 | tee s3_outfile.out
48
+
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and c ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s3_outfile.out
49
49
pyccel-clean
50
50
shell: ${{ inputs.shell_cmd }}
51
51
working-directory: ./tests
52
52
id: pytest_3
53
53
- name: Test Fortran translations
54
-
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and not (c or python) ${{ inputs.pytest_mark }}" --ignore=symbolic --ignore=ndarrays 2>&1 | tee s4_outfile.out
54
+
run: python -m pytest -n auto -rX ${FLAGS} -m "not (parallel or xdist_incompatible) and not (c or python) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s4_outfile.out
55
55
shell: ${{ inputs.shell_cmd }}
56
56
working-directory: ./tests
57
57
id: pytest_4
58
58
- name: Test multi-file Fortran translations
59
59
run: |
60
-
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and not (c or python) ${{ inputs.pytest_mark }}" --ignore=symbolic --ignore=ndarrays 2>&1 | tee s5_outfile.out
60
+
python -m pytest -rX ${FLAGS} -m "xdist_incompatible and not parallel and not (c or python) ${{ inputs.pytest_mark }}" --ignore=ndarrays 2>&1 | tee s5_outfile.out
Copy file name to clipboardExpand all lines: docs/quickstart.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -453,6 +453,35 @@ Out[9]: 210.99245283018868
453
453
```
454
454
After subtracting the amount of time required to create an array copy from the given times, we can conclude that the pyccelised function is approximately 210 times faster than the original Python function.
455
455
456
+
### Interactive Usage with `lambdify`
457
+
458
+
While Pyccel is usually used to accelerate Python code, it is also possible to accelerate other expressions. The Pyccel library provides the `lambdify` Python function. This function is similar to SymPy's [`lambdify`](https://docs.sympy.org/latest/modules/utilities/lambdify.html) function, given a SymPy expression `f` and type annotations, `lambdify` returns a "pyccelised" function `f_fast` that can be used in the same Python session.
In practice `lambdify` uses SymPy's `NumPyPrinter` to generate code which is passed to the `epyccel` function. The `epyccel` function copies the code into a temporary Python file in the `__epyccel__` directory.
482
+
Once the file has been copied, `epyccel` calls the `pyccel` command to generate a Python C extension module that contains a single pyccelised function.
483
+
Then finally, it imports this function and returns it to the caller.
484
+
456
485
## Other Features
457
486
458
487
Pyccel's generated code can use parallel multi-threading through [OpenMP](https://en.wikipedia.org/wiki/OpenMP); please read [our documentation](https://github.com/pyccel/pyccel/blob/master/tutorial/openmp.md) for more details.
0 commit comments