MAINT: prepare to speed up some parts of the code using C: