Commit 86be631
Speed up of
This speeds up calls to `cross_section` by a factor of 3 😮
There is some slow down of the cross section calculation described in
#244 .
This reduces the number of internal calls of `cross_section` due to
`_temporary_kinematics` context manager.
Before PR:
```python
In [2]: from chromo.kinematics import FixedTarget
...: from chromo.models import Sibyll23e
In [3]: kin_init = FixedTarget(100, 2212, 'O16')
...: kin = FixedTarget(80, 2212, 'O16')
...:
...:
...: sib = Sibyll23e(kin_init)
In [4]: def cs(mod, kin):
...: return mod.cross_section(kin).prod
...:
In [5]: %timeit cs(sib, kin)
992 μs ± 252 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
```
With this PR:
```python
In [8]: %timeit cs(sib, kin)
328 μs ± 791 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
```
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>cross_section 💨 (#245)1 parent 22e638a commit 86be631
1 file changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
813 | | - | |
| 813 | + | |
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | | - | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
1014 | 1016 | | |
1015 | | - | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
0 commit comments