|
Re: Support for Indexing and Iteration Safety: msg#00353python.c++
> > <snip my entire posting quoted> oops, apologies for the noise. > > > I'm haven't gone far enough in what I am doing to encounter these > > problems, but for what its worth, at the moment I would have done > > the following: > > > > if something is lightweight, return a copy > > if it is big, use shared_ptr > > > > Which means that the above problems 3 & 4 would not occur. > > That is only true if you can modify your vector to be a > vector<shared_ptr<SomeBigObject> >. Often, the implementation of code > being wrapped can't be intrusively changed in that way. - Right -- but in my case, I'm writing that code as well, so I can be as intrusive as I want (you did ask if it bothered *me*) > Furthermore, even if it's lightweight, returning a copy gets you > unpredictable behavior like: > > >>> v[3].foo = 1 > >>> v[3].foo > 22 > > because you've only set the attribute on the copy. > It won't crash, but it is annoying. Okay, *really* annoying. > > Did I change your mind yet? ;-> > If you could solve the above problem it would be great. But I can live without it. I realise I am in a somewhat unique position though. I am the producer of the C++ lib, and the python lib - AND I am the only consumer. So I can live happily with workarounds. If I was publishing my material for general consumption, I might be thinking differently. > <snip a duplicate copy of the entire foregoing text> > Ugh -- must learn decent newsreader and stop cutting and pasting. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [newbie] Failing to test boost.python under cygwin: 00353, Gilles Orazi |
|---|---|
| Next by Date: | custom less than operator? to_python_converter for multiple destination types?: 00353, Gavin Doughtie |
| Previous by Thread: | Re: Support for Indexing and Iteration Safetyi: 00353, David Abrahams |
| Next by Thread: | Re: Support for Indexing and Iteration Safety: 00353, Mike Rovner |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |