Re: [sage-devel] making tuples in cython

2013-10-21 Thread Tom Boothby
On Mon, Oct 21, 2013 at 11:03 AM, Robert Bradshaw wrote: > You can iterate over a vector using "for x in ..." rather than indexing > though. > Nice. I do love cython. Every time I use it for something new, I learn that features "just work" that I never thought to try. Thanks for your help! -

Re: [sage-devel] making tuples in cython

2013-10-21 Thread Robert Bradshaw
There's not a way to construct tuples without the intermediate lists without using the C API directly. You can iterate over a vector using "for x in ..." rather than indexing though. On Mon, Oct 21, 2013 at 10:42 AM, Tom Boothby wrote: > Okay, that's almost okay... but I'm getting a list of lists

Re: [sage-devel] making tuples in cython

2013-10-21 Thread Tom Boothby
Okay, that's almost okay... but I'm getting a list of lists from the following code -- is it possible to get a tuple of tuples instead? I guess I can just avoid tossing the list back to the user if not. %cython #clang c++ from libcpp.vector cimport vector def tupletuple(vector[vector[int]] M):

Re: [sage-devel] making tuples in cython

2013-10-21 Thread Tom Boothby
lol, really? Can I then toss that back to python? On Mon, Oct 21, 2013 at 10:19 AM, Robert Bradshaw wrote: > How about > > cdef tupletuple(vector[vector[int]] M): > return M > > On Mon, Oct 21, 2013 at 8:48 AM, Tom Boothby wrote: >> I'm working on overhauling a class (see [1]) that

Re: [sage-devel] making tuples in cython

2013-10-21 Thread Robert Bradshaw
How about cdef tupletuple(vector[vector[int]] M): return M On Mon, Oct 21, 2013 at 8:48 AM, Tom Boothby wrote: > I'm working on overhauling a class (see [1]) that wraps some c++, and > I've got just about everything working how I want... but I have a > nagging doubt about performance

[sage-devel] making tuples in cython

2013-10-21 Thread Tom Boothby
I'm working on overhauling a class (see [1]) that wraps some c++, and I've got just about everything working how I want... but I have a nagging doubt about performance. Is the following fast? Can it be made fast without a bunch of ugly python c-api stuff? cdef tupletuple(vector[vector[int]] M):