On May 7, 2009, at 2:03 AM, Dag Sverre Seljebotn wrote:

>> OK, that changes everything. It still has its issues though. I'd
>> assume you'd try to delete the C++ object on deallocation? But what
>> if two distinct Python objects refer to the same C++ object? Or  
>> the C+
>> + object (pointer) gets passed and stored in some library somewhere?
>
> All crossings between Cython and C++ would pass the object by  
> value. You'd
> still need to use & to get a pointer, which would be similar to str ->
> char*.
>
>> I don't see a way to ensure a one-to-one relationship between C++
>> objects and Python objects--short of having stack allocated semantics
>> (i.e. it goes out of scope and is deconstructed when the function
>> exits) I don't see how one can automatically refcount C++ classes.
>
> I don't see the problem, sorry.

I hadn't seen your retraction of "also changes b" so I thought you  
were trying to pass things around by reference. Then what does

b = a

actually do? Construct a new Python object, then copy by value into  
it, and assign to be? So

a is b

is now False?

>> You know people are then going to want to have access to all it's
>> methods and members, so that just declaring the C++ class will be
>> creating a full-fledged wrapper around it. I can just see the
>> expectations now :).
>
> Well, obviously that is down the pipeline, but no need to go there  
> now.
>
> I just want *some* way to avoid having to write it[0][0] to  
> dereference an
> STL iterator. Everything else is secondary really :-)

Yeah, me too :-)

>
>>
>>> However note that this might have consequences for how
>>> operators should be defined (I haven't seen a concrete proposal for
>>> what
>>> you are thinking there so I don't know how it would fare).
>>
>> http://www.mail-archive.com/[email protected]/msg05140.html
>
> Hmm. So how would e.g. += be treated?

Perhaps we could declare it as having an __iadd__ operator, but  
realistically it might make sense to disallow all assignment  
operators for the first pass.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to