py: Refactor slice helpers, preparing to support arbitrary slicing.