<snip>
This reminds me of a function [1] I wrote which I think has a lot of
similarities to what Stephan describes here. It is currently part of a
PR to rewrite numpy.pad [2].
If we start to write the equivalent internally, then perhaps we should indeed expose it!
Would my trial indeed help, or is it insufficient? (Sorry for not checking myself in detail; it is not immediately obvious.)
-- Marten