Looking at the source code of _functoolsmodule.c , I don't think there is anything to worry about.
The partial module implementation handles etching and repr , but everything else looks like it works as in the documentation, so the reason why it is implemented in C seems to be just efficiency. There is also the fact that this is a type, not just a function closure.
Note, however, that in the sample documentation, func , args and keywords are purely cosmetic; they are not excessive, as in real instances of functools.partial . One alternative would be a subclass of functools.partial :
class rpartial(partial): def __call__(self, *args, **kwargs): kw = self.keywords.copy() kw.update(kwargs) return self.func(*(args + self.args), **kwargs)
ecatmur
source share