why () is () and [] is [] work in other way?

Chris Angelico rosuav at gmail.com
Sat Apr 28 07:40:59 EDT 2012


On Sat, Apr 28, 2012 at 9:26 PM, Kiuhnm
<kiuhnm03.4t.yahoo.it at mail.python.org> wrote:
> Your problem is that you think that copy semantics requires real copying. I
> really don't see any technical difficulty in virtualizing the all thing.

"Copy semantics" without "real copying" is an optimization that a
program should never need to be aware of. For instance, you could have
two 16GB strings share their buffers to avoid having to use 32GB of
memory; but to demonstrate copy semantics, they would need to
copy-on-write in some fashion. There's duplicate state but shared
memory. The trouble with duplicating state of a std::fstream is that
it's roughly impossible. You could perhaps simulate it with read-only
file access, but when you write, somehow it has to affect the disk,
and that means either you copy the file (but keep the same file name)
or have both of them affect the same file (meaning we're on Borg
semantics, not copying).

ChrisA



More information about the Python-list mailing list