>>
>> I don't get why you need to manually do it. Doesn't the c++ default
>> construction just do it for you?
>
> No, because the memory for the class object is allocated deep withing
> the Python library with an ordinary malloc, and the pointers just
> passed around.

I see. I should have thought of that. So in-place construction would
have to be done.

>>
>> Nastiness explained: Vector2d is a struct with 2 float members. I
>> declare 2 float members in the python object, and then get a pointer
>> to the first of these and cast it to a Vector2d. Assuming that the
>> struct layout is the same in both of these, then accessing members via
>> the cython properties will update the same shared bit of memory that
>> the c++ struct uses.
>
> If this is just for syntactic sugar, it sound way to messy... I could
> see simplifications of the properties syntax to make Python access
> easier.
>

Yes -- it is way too messy.

.
>
> setters, getters, (and delattrs?) would be defined iff they make sense
> on the expression in question. One could imagine
>
>    property readonly obj.x as x
>
> or something like that. I'm not a fan of the = sign, as it's no where
> else used for declarations (it's always a statement), unless we do
> something like
>

I agree that the = sign is confusing. And both "property" and "as"
should be familiar to python users.

In any case, this would be a nice addition. Where would I look to do
something like this? Is it a big thing?

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

Reply via email to