git: speed up possible head processing during indexing by ~100x
Benchmarking of 50 iterations of indexing (see below) shows that there is
essentially no difference for small repos (<1k commits), similarly medium
repos (~12k commits) see some benefit but other overheads completely
overwhelm it, but for large repos (~122k commits) the 80-100x speedup is
clearly visible to the user.
All of the numbers are in seconds and were measured with time.time() calls
placed in _index_repo(). The times exclude the time taken by changedfiles
processing.
Small repo (guilt, 553 commits, 1 head):
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.0008781 0.0009274 0.0009800 0.0012285 0.0014637 0.0024107 (before)
0.0003092 0.0003281 0.0003519 0.0003777 0.0003927 0.0006843 (after)
Medium repo (hamlib, 12k commits, 53 heads):
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.04881 0.05135 0.07632 0.06672 0.08042 0.09415 (before)
0.004249 0.004420 0.004799 0.004809 0.005051 0.006416 (after)
Large repo (qemu, 122k commits, 50 heads):
Min. 1st Qu. Median Mean 3rd Qu. Max.
4.274 4.595 4.832 6.578 8.397 9.721 (before)
0.05180 0.05643 0.05865 0.06130 0.06712 0.06872 (after)
rust-pyo3-sharedref: demonstrate SharedByPyObject borrow unsafety
We take the existing doc-comment from rust-cpython and make it
compile (validated by `cargo test`). With the added explanations,
the ordinary comment was no longer useful, we could therefore
remove it.
The new explanation stresses that "not leaking the internal faked
reference" is definitely not enough, because the problem is about
*all references* that can be derived from it.
We ended up duplicating the explanation, because that is a way
to ensure that people do not miss it. Also, it was a bit misleading
that the previous example was for `try_borrow_mut()`, so we made
a similar, simpler one for `try_borrow()`.