Reduce code in doc code examples. [ci skip]
Add `partition`.