Pass-by-reference : Could a C#-like approach work in Python?

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Thu Sep 11 15:41:52 EDT 2003


On Thu, 11 Sep 2003 10:22:22 -0700, Michael Chermside
<mcherm at mcherm.com> wrote:

>> if copying is costly and only
>> sometimes necessary, wrap the item into a copy-on-write proxy for every
>> logically distinct but physically identical instance.
>
>Excellent idea! But, how do I write a copy-on-write proxy in Python?

I suspect this is one of those things which is doable, but you end up
having to write a specialised proxy for each case (ie each class being
proxied). Depending on how many methods you need to support, it may
not be that much of a headache of course.

There are other ways of doing it that don't need a change to Python,
though - I guess the particular method will probably depend on
particular cases.

>To add even
>that one boolean property would significantly complicate callables.

Absolutely true - it should only for affect calls with at least one
'ref' parameter, but even then, without a compelling use case this
more than enough reason to reject the idea.

>I'd-cc-Stephen-Horne-directly-but-it'd-be-rejected-as-a-Nigerian-scam lly,

You'd have a hard job - just noticed my sig is missing from my posts,
and my e-mail address deliberately isn't in the header field.

I'll fix the sig in a minute, when I can face the newsreaders
settings, but if its needed my email is steve at ninereeds dot fsnet
dot co dot uk.





More information about the Python-list mailing list