libdynd / dynd-python

Python exposure of dynd
http://libdynd.org
Other
119 stars 23 forks source link

Refcounting Smart Pointers #702

Open insertinterestingnamehere opened 8 years ago

insertinterestingnamehere commented 8 years ago

So, as this is, things still segfault, and there's a compilation error with MSVC that I need to track down. I'll put this up here anyway so we can discuss the proposed API while I track down the remaining errors. I also still need to add an assignment operator that allows moving from an rvalue reference.

Ultimately, I'd like to see a class like this used to interface between our binding code that's written in C++ and Cython. It'd be ideal if we could also use classes like this to interact with many of the built in Python C API functions. The goal there would be to make it so that compile-time errors can be thrown when a function is used with incorrect reference semantics or null handling. Encoding thse semantics into the type system seems like a good way to do that.

insertinterestingnamehere commented 8 years ago

I think this is good to go now. The test failures are not related to this PR.

Here are my future plans with this (in no particular order):

mwiebe commented 8 years ago

One high level question - is there a description of how they work and why they're designed the way they are, so that people using them can refer to that to develop their mental model of correct vs incorrect code? Would be good to link to that description from the README/getting started.

insertinterestingnamehere commented 8 years ago

Thus far I've just been doing that via thorough commenting. I can put together a design doc if you'd like though.

mwiebe commented 8 years ago

That would be awesome, yeah, When I first used the python C API, I found https://docs.python.org/2/c-api/intro.html#reference-counts very useful to orient myself about reference counts, you might call out specific things from there and describe how the types you've created make it easier to produce correct code.

insertinterestingnamehere commented 8 years ago

Sure, that sounds like a great idea. I'll add that in here as well. Thanks!