Commit d7157b4
committed
Cache realpath resolution in font_manager.
This shaves off ~33% runtime from
```python
from pylab import *
import timeit
tx = figtext(.5, .5, "foo\nbar baz")
gcf().canvas.draw()
gcf().patch.set_visible(False)
r = gcf()._cachedRenderer
n, t = timeit.Timer(lambda: tx.draw(r)).autorange(); print(t / n, n, t)
```
because previously the calls to realpath were not cached and filesystem
access is slow.
(The font cache is likely already in trouble if fonts move in the
filesystem within the execution of a program given that there are other
layers of cache, so I wouldn't overly worry about that. At best we may
want to expose a manual function to invalidate all caches if someone
really runs into that problem.)1 parent 86f1ea7 commit d7157b4
1 file changed
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
164 | 169 | | |
165 | 170 | | |
166 | 171 | | |
| |||
1308 | 1313 | | |
1309 | 1314 | | |
1310 | 1315 | | |
1311 | | - | |
| 1316 | + | |
1312 | 1317 | | |
1313 | 1318 | | |
1314 | | - | |
1315 | 1319 | | |
1316 | 1320 | | |
1317 | 1321 | | |
| |||
1382 | 1386 | | |
1383 | 1387 | | |
1384 | 1388 | | |
1385 | | - | |
| 1389 | + | |
1386 | 1390 | | |
1387 | 1391 | | |
1388 | 1392 | | |
| |||
1411 | 1415 | | |
1412 | 1416 | | |
1413 | 1417 | | |
1414 | | - | |
| 1418 | + | |
1415 | 1419 | | |
1416 | 1420 | | |
1417 | | - | |
| 1421 | + | |
1418 | 1422 | | |
1419 | 1423 | | |
1420 | 1424 | | |
| |||
0 commit comments