Re: python data types in c++ code

2011-03-07 Thread Stefan Behnel

Dan Stromberg, 07.03.2011 03:47:

On Sun, Mar 6, 2011 at 10:07 AM, Arthur Mc Coy wrote:

You know, they are still using SVN, they are
very loosely coupled to the past.


about SVN: I'm not sure it's really dying.


I hope it will.



Yes, a lot of distributed
development has moved off of SVN, and is better off for having done so, but
I believe some environments (especially corporate environments) just prefer
having a central server.


DVCSs do not prevent you from having a central server. They just keep you 
from having to rely on it. That's a big plus, also in corporate environments.


Worth a read: http://hginit.com/00.html

Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Stefan Behnel

Arthur Mc Coy, 06.03.2011 17:40:

Ok, I managed to work with c++ data types in python and can store
serialize c++ objects to store in json.

Now the task is backward. I wrote a c++ code to get the list of
objects using again python interface. The list of objects is returned.
PyList.

But I can't see how to convert PyObject as element of PyList to c++
data type or even how to convert or iterate PyList which is PyObject
too.

Please, whisper me the proper way I will go for.


You mentioned using SWIG, but I'd actually suggest using Cython instead. It 
will make it a lot easier (and faster) for you to convert data types 
between Python and C/C++ (and will also allow you to skip over most 
ref-counting problems). Since you appear to know C++ anyway, you should be 
able to get comfortable with it quite quickly.


http://cython.org

Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Ok people,


I do:
for (Py_ssize_t i = 0; i PyList_Size(py_list); ++i) {
 PuObject* obj = PyList_GetItem(py_list, i);
 if (obj != NULL) {
   // howto get obj properties of different types
(map, list, string, int, bool) ?
 }
}

Very clear code. The question is in the comment :)
Let's play more,
it's like jazz,
let's explore,
Baby baby baby bass


Keep yourselves,
Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stefan, great suggestion !!

I will definitely bookmark this page and consider later. But my
project dictate me use SWIG. I'm almost near the happy subend. Very
curios on question I asked in previous message.

Dear all, I love you too much :)

Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
Stephan, you are lead developer over there :))) It's marketing,
however very nice solution.. I will propose my bosses to rediscover
their world assumptions. You know, they are still using SVN, they are
very loosely coupled to the past. I have to wash their brains...

Meantime still battling with PyObject properties which are so diverse
and disperse that I don't know...


Keep talking guys


Arthur
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Arthur Mc Coy
In short, the answer is to use PyObject dictionary ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Stefan Behnel

Arthur Mc Coy, 06.03.2011 19:07:

Stephan, you are lead developer over there :))) It's marketing,


Let's say, as a core developer of Cython, I'm well aware of it's virtues, 
and I can tell you that my suggestion is actually well backed by the user 
feedback we get. You will find some of it on the right side of cython.org. 
The selection there is obviously biased, but I can confirm that it really 
matches with most of the non-technical feedback we get. Cython has a lot of 
happy users, and that's very rewarding to its core developers.


Stefan

--
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Miki Tebeka
// howto get obj properties of different types
 (map, list, string, int, bool) ?
Python's C API is very well documented. You can use 
http://docs.python.org/c-api/object.html?highlight=pyobject#PyObject_GetAttr to 
get attributes or 
http://docs.python.org/c-api/object.html?highlight=pyobject#PyObject_GetItem to 
get items (from dictionaries and maps).

HTH
--
Miki Tebeka miki.teb...@gmail.com
http://pythonwise.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python data types in c++ code

2011-03-06 Thread Dan Stromberg
On Sun, Mar 6, 2011 at 10:07 AM, Arthur Mc Coy 1984docmc...@gmail.comwrote:

 You know, they are still using SVN, they are
 very loosely coupled to the past.


Cython's very nice if you don't plan to do more than C/C++ with Python.
SWIG might be better if you intend to do more VHLL's than Python alone.

But about SVN: I'm not sure it's really dying.  Yes, a lot of distributed
development has moved off of SVN, and is better off for having done so, but
I believe some environments (especially corporate environments) just prefer
having a central server.
-- 
http://mail.python.org/mailman/listinfo/python-list