[SciPy-Dev] Move some validations as asserts?

Evgeni Burovski evgeny.burovskiy at gmail.com
Tue Mar 2 16:56:25 EST 2021


> TL;DR: could we use assert to do validation?
>
> In a recent issue (https://github.com/scipy/scipy/issues/13629), the cost of validation was raised in context such as optimization.
> In situations like these, or even when you know how to use the API, there are lots of unnecessary validations happening.
>
> I would propose a general reflection around validation.
>
> Some ideas:
>
> A simple approach would be to systematically separate the logic in two: core function on one side, user interface on the other. This way the user could by-pass all the time the validation.
> Mock the validations. After some quick tests, it looks like the overhead is too big. I could be wrong.
> Using assert for all validation.

The first option sounds best to me.

My 2c,

Evgeni


More information about the SciPy-Dev mailing list