On Wed, Jan 13, 2021 at 08:17:26PM +0300, Paul Sokolovsky wrote:

> > Besides, we probably don't want to prohibit side-effects in
> > `__bool__`. That would prohibit useful tricks such as putting logging
> > calls into a method you are trying to debug.
> 
> Surely, if we do that, we wouldn't use Haskell's definition of
> purity ;-). Rather, a practical definition of purity, Python-style.

It's not *Haskell's* definition, it's pretty much *everyone's* 
definition of pure.

https://en.wikipedia.org/wiki/Pure_function



> For example, print() would be considered "pure", as its purpose is to
> provide program output, not arbitrarily change program state


Is writing to an external file a change to program state? Keep in mind 
that programs can get state from external files.

I would say that what you are describing is not a distinction between 
pure and impure functions, based on whether or not they can be safely 
optimised away without a change in visible behaviour. The distinction 
you are proposing is into two arbitrary sets of functions, some of which 
can be optimized away and some which can't, regardless of whether or not 
that optimisation leads to change in visible behaviour.

If you want to argue for that, fine, do so, but don't call impure 
functions "pure".


-- 
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/FKSAUJVPPP2JV56T4BIB7W3B6GD63HGE/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to