• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hgrecco / pint / 1331 / 6
91%
master: 91%

Build:
DEFAULT BRANCH: master
Ran 09 Dec 2019 06:56PM UTC
Files 16
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Dec 2019 06:45PM UTC coverage: 85.972% (-0.08%) from 86.052%
PKGS="python=3.6 numpy=1.14"

push

travis-ci

web-flow
Merge #923

923: Preserve caches on context switch v2 r=hgrecco a=crusaderky

Fix bug in #909 where, every time a context is reactivated, it creates a brand new entry in UnitRegistry._caches - thus not only nullifying the whole point of the PR, but also creating a nasty memory leak for users that invoke ``.to`` with an inline context many times.

Not sure what went wrong with the first PR - if I rerun the included benchmark, it doesn't reproduce the same results anymore and clearly shows that nothing is cached.

Same benchmark with this PR:
```python
import pint
ureg = pint.UnitRegistry()
src = ureg('1 m')
dst = ureg.Unit('km')
%timeit src.to(dst)
%timeit -n 1 -r 1 src.to(dst, 'chemistry')
%timeit src.to(dst, 'chemistry')
ureg.enable_contexts('chemistry')
%timeit src.to(dst)
```
29.9 µs ± 1.4 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
57.3 ms ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)
76.9 µs ± 1.69 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
43.7 µs ± 955 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

Co-authored-by: Guido Imperiale <crusaderky@gmail.com>

2911 of 3386 relevant lines covered (85.97%)

0.86 hits per line

Source Files on job 1331.6 (PKGS="python=3.6 numpy=1.14")
  • Tree
  • List 0
  • Changed 3
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 1228
  • Travis Job 1331.6
  • a741670e on github
  • Prev Job for PKGS="python=3.6 numpy=1.14" on master (#1316.6)
  • Next Job for PKGS="python=3.6 numpy=1.14" on master (#1336.6)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc