[Cython] New idea for C++ stack allocation
Robert Bradshaw
robertwb at math.washington.edu
Wed May 6 11:39:06 CEST 2009
On Apr 27, 2009, at 11:57 PM, Dag Sverre Seljebotn wrote:
> I got another idea for how using C++ objects without no-arg
> constructors
> could work. It means enforcing C++ variable scoping through compile-
> time
> errors, but keeping Python syntax.
I think for our first pass at least, we should allocate everything on
the heap. We could then try to (transparently?) move things to the
stack when we can (this would have implications for passing things
around though).
> The transform necesarry to enforce these rules should not be too
> complicated. I don't think we need full analysis, just track
> assignments
> and deletions and usages on a per-name basis.
>
> Finally, the C++ output is made by adding a block, i.e.
>
> cdef CppObject obj
> print 1
> obj = bar
> obj.func()
> del obj
> print 2
>
> Results in
>
> print 1
> {
> CppObject obj = bar;
> obj.func()
> } # del
> print 2
What about
cdef CppObject a, b
a = bar
b = bar
del a
del b
?
- Robert
More information about the Cython-dev
mailing list