Indentation and optional delimiters

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Feb 26 16:59:31 EST 2008


On Tue, 26 Feb 2008 05:36:57 -0800, bearophileHUGS wrote:

> So it can be invented a language
> (that may be slower than Python, but many tricks and a JIT may help to
> reduce this problem) where
> 
> a = [1, 2, 3]
> b = a
> Makes b a copy-on-write copy of a, that is without reference semantics.

Usability for beginners is a good thing, but not at the expense of 
teaching them the right way to do things. Insisting on explicit requests 
before copying data is a *good* thing. If it's a gotcha for newbies, 
that's just a sign that newbies don't know the Right Way from the Wrong 
Way yet. The solution is to teach them, not to compromise on the Wrong 
Way. I don't want to write code where the following is possible:

a = [gigabytes of data]
b = a
f(a) # fast, no copying takes place
g(b) # also fast, no copying takes places
... more code here
... and pages later
b.append(1)
... suddenly my code hits an unexpected performance drop
... as gigabytes of data get duplicated



-- 
Steven



More information about the Python-list mailing list