[Python-3000] PEP 3137 plan of attack
Luke Stebbing
luke.stebbing at gmail.com
Mon Oct 15 20:33:46 CEST 2007
On 10/15/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> If returning the original (but mutated) buffer is a problem, then
> there is already a problem, because someone else could already mutate
> the original.
>
> (Also note that for duck-typing, it should be OK if the new result
> object is always immutable, since you have to handle that case
> anyhow.)
Changing the contract of a function can really mess with duck-typing.
If you write a function that internally creates a lowered copy of a
variable (for comparison, say), suddenly you're unintentionally
lowering your argument in-place. Even returning an immutable result
object is a problem, because your contract changes from "I return a
lowered, rjusted copy of my argument" to "I return a lowered rjusted
copy of my argument that -- oops -- is immutable now if it wasn't
before".
Luke
More information about the Python-3000
mailing list