On Fri, 08 Oct 2010 18:02:15 +0200, Jonas H. wrote:
> On 10/08/2010 05:23 PM, Carolyn MacLeod wrote:
>> "How do I pass an integer by reference to a C function?"
>
> That's impossible in pure Python. The only thing I can think of is a
> wrapper in C.
I didn't see the original message, but if you
On 10/08/2010 05:23 PM, Carolyn MacLeod wrote:
"How do I pass an integer by reference to a C function?"
That's impossible in pure Python. The only thing I can think of is a
wrapper in C.
--
http://mail.python.org/mailman/listinfo/python-list
Hi.
This is kind of a cross-product question, having to do with accessibility
on Linux using ATK (AT-SPI).
However, I think it really boils down to a python question: "How do I pass
an integer by reference to a C function?"
I am using Accerciser (http://live.gnome.org/Accerciser), an accessibi
>>> As others already said, using a Numpy array or an array.array object
>>> would
>>> be more efficient (and even easier - the C code gets a pointer to an
>>> array
>>> of integers, as usual).
>>
>> I looked for this in the C API docs but couldn't find anything on how
>> to make an array.array pyt
En Sun, 28 Dec 2008 01:47:08 -0200, Daniel Fetchinson
escribió:
As others already said, using a Numpy array or an array.array object
would
be more efficient (and even easier - the C code gets a pointer to an
array
of integers, as usual).
I looked for this in the C API docs but couldn't
python.org/c-api/arg.htmlfrom which I learned how to pass
> a fixed number of basic datatypes (int, float, string) from python to
> C and back. What I don't know is how to pass an array back and forth.
>
> As far as I can see PyArg_ParseTuple is the function I should use for
> conv
>>> You MUST check EVERY function call for errors!
>>
>> Yes, I know :)
>>
>
> Believe me, if you don't, there is a risk of crashing the program. And
> they're a lot harder to find and fix.
Sure, what I meant by the smiley is just that it was a quick and dirty
example, not real code. In a real cod
>> This is the function I have, the corresponding python function will
>> take two equal length lists of integers and the C function will
>> compute their sum and return the result as a python tuple.
>>
>>
>> static PyObject *func( PyObject * self, PyObject * args )
>> {
>> int j, N;
>> int
En Sun, 28 Dec 2008 00:40:52 -0200, Daniel Fetchinson
escribió:
You MUST check EVERY function call for errors!
Yes, I know :)
Believe me, if you don't, there is a risk of crashing the program. And
they're a lot harder to find and fix.
And check the argument's type (how do you know i
I agree that array.array is more efficient than a list but the input
for my function will come from PIL and PIL returns a list. So I have a
list to begin with which will be passed to the C function.
>>> With recent versions of PIL, numpy can create an array from an Image very
>>> qui
>> This is the function I have, the corresponding python function will
>> take two equal length lists of integers and the C function will
>> compute their sum and return the result as a python tuple.
>>
>>
>> static PyObject *func( PyObject * self, PyObject * args )
>> {
>> int j, N;
>> int
Daniel Fetchinson wrote:
I agree that array.array is more efficient than a list but the input
for my function will come from PIL and PIL returns a list. So I have a
list to begin with which will be passed to the C function.
With recent versions of PIL, numpy can create an array from an Image ver
En Sat, 27 Dec 2008 22:54:52 -0200, Daniel Fetchinson
escribió:
This is the function I have, the corresponding python function will
take two equal length lists of integers and the C function will
compute their sum and return the result as a python tuple.
static PyObject *func( PyObject * se
On 12/27/08, Robert Kern wrote:
> Daniel Fetchinson wrote:
>
>> I agree that array.array is more efficient than a list but the input
>> for my function will come from PIL and PIL returns a list. So I have a
>> list to begin with which will be passed to the C function.
>
> With recent versions of P
On Dec 27, 6:06 pm, Scott David Daniels wrote:
> Daniel Fetchinson wrote:
> > I have a list to begin with which will be passed to the C function.
>
> > I assume converting the list to an array.array and passing that to the C
>
> > function doesn't make any difference in terms of speed since t
>> I agree that array.array is more efficient than a list but the input
>> for my function will come from PIL and PIL returns a list. So I have a
>> list to begin with which will be passed to the C function.
>
> With recent versions of PIL, numpy can create an array from an Image very
> quickly, po
Daniel Fetchinson wrote:
I agree that array.array is more efficient than a list but the input
for my function will come from PIL and PIL returns a list. So I have a
list to begin with which will be passed to the C function.
With recent versions of PIL, numpy can create an array from an Image v
Daniel Fetchinson wrote:
I have a list to begin with which will be passed to the C function.
> I assume converting the list to an array.array and passing that to the C
function doesn't make any difference in terms of speed since the
operation itself will be done in the C function anyway.
>> I have considered using ctypes but for my needs using the C API
>> directly seems more reasonable. array.array and numpy.array doesn't
>> fit my needs since I need to do long and complicated operations on the
>> two (pretty large) integer arrays that would be too slow using
>> array.array and nu
Daniel Fetchinson wrote:
I have considered using ctypes but for my needs using the C API
directly seems more reasonable. array.array and numpy.array doesn't
fit my needs since I need to do long and complicated operations on the
two (pretty large) integer arrays that would be too slow using
array.
also an N length array. From python I'd like to call this
>> function as
>> ret = func( [ 1, 2, 3 ], [ 2, 3, 4] )
>
> This requirement pretty much dictates the slow answer you have.
I'm not sure I understand what you mean.
> > Does this mean that I can only pas
array. From python I'd like to call this
function as
ret = func( [ 1, 2, 3 ], [ 2, 3, 4] )
This requirement pretty much dictates the slow answer you have.
> Does this mean that I can only pass the arrays from python to C as
> generic python objects and in a later operation I need to ge
ke to call this
function as
ret = func( [ 1, 2, 3 ], [ 2, 3, 4] )
I've read through the docs at
http://docs.python.org/extending/extending.html and also
http://docs.python.org/c-api/arg.html from which I learned how to pass
a fixed number of basic datatypes (int, float, string) from python to
C
On Oct 16, 9:10 am, Hongtian wrote:
snip
> Not exactly.
> In my C/C++ application, I have following function or flow:
> void func1()
> {
> call PyFunc(struct Tdemo, struct &Tdemo1);
> }
> I mean I want to invoke Python function 'PyFunc' and transfer a data
> structure 'Tdemo' to this fu
En Tue, 21 Oct 2008 15:21:45 -0200, Aaron Brady <[EMAIL PROTECTED]>
escribió:
On Oct 21, 12:46 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
Hi Gabriel,
Sorry, did you have some questions about it?
No, that empty message was posted by mistake, sorry.
--
Gabriel Genellina
--
http://mail
On Oct 21, 12:46 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 17 Oct 2008 20:03:44 -0300, Aaron "Castironpi" Brady
> <[EMAIL PROTECTED]> escribió:
>
>
>
> > On Oct 16, 9:10 am, Hongtian <[EMAIL PROTECTED]> wrote:
> >> Not exactly.
>
> >> In my C/C++ application, I have following f
En Fri, 17 Oct 2008 20:03:44 -0300, Aaron "Castironpi" Brady
<[EMAIL PROTECTED]> escribió:
On Oct 16, 9:10 am, Hongtian <[EMAIL PROTECTED]> wrote:
Not exactly.
In my C/C++ application, I have following function or flow:
void func1()
{
call PyFunc(struct Tdemo, struct &Tdemo1);
}
I
On Oct 16, 9:10 am, Hongtian <[EMAIL PROTECTED]> wrote:
> Not exactly.
>
> In my C/C++ application, I have following function or flow:
>
> void func1()
> {
> call PyFunc(struct Tdemo, struct &Tdemo1);
>
> }
>
> I mean I want to invoke Python function 'PyFunc' and transfer a data
> structure
a newer of Python. I want to ask below question:
>
> > > I have a C/C++ application and I want to use Python as its extension.
> > > To do that, I have to transfer some data structure from C/C++
> > > application to Python and get some data structure from Python to C/C++
a newer of Python. I want to ask below question:
>
> > > I have a C/C++ application and I want to use Python as its extension.
> > > To do that, I have to transfer some data structure from C/C++
> > > application to Python and get some data structure from Python to C/C++
On Oct 16, 9:10 am, Hongtian <[EMAIL PROTECTED]> wrote:
> Not exactly.
>
> In my C/C++ application, I have following function or flow:
>
> void func1()
> {
> call PyFunc(struct Tdemo, struct &Tdemo1);
>
> }
>
> I mean I want to invoke Python function 'PyFunc' and transfer a data
> structure
te:
> On Oct 15, 8:08 pm, Hongtian <[EMAIL PROTECTED]> wrote:
>
> > Hi friends,
>
> > I am a newer of Python. I want to ask below question:
>
> > I have a C/C++ application and I want to use Python as its extension.
> > To do that, I have to transfer s
plication to Python and get some data structure from Python to C/C++
> application. I have researched Python document, but the example only
> describes how to transfer some simple data, such as integer,char,
> etc.
>
> Could you please guide me to do that? or tell me some document to
Hongtian:
> Could you please guide me to do that? or tell me some document to have
> a research?
You can start googling for:
- SWIG
- Boost.Python
- SIP
- ctypes (built-in module)
- And more.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Hi friends,
I am a newer of Python. I want to ask below question:
I have a C/C++ application and I want to use Python as its extension.
To do that, I have to transfer some data structure from C/C++
application to Python and get some data structure from Python to C/C++
application. I have
brad schrieb:
> However, other components can be written in a more user friendly, more
> easily maintained language. We've chosen Python for this. The main
> question now is how to pass the computationally heavy info to c++ from
> within Pyhton. os.system is not ideal. Just wondering how other folk
In article <[EMAIL PROTECTED]>, brad <[EMAIL PROTECTED]>
wrote:
> I have some c++ binaries that do rather intense number computations.
> They do it well and rather quickly compared to other languages (not just
> Python). ...
>
> However, other components can be written in a more user friendly,
brad wrote:
I have some c++ binaries that do rather intense number computations.
They do it well and rather quickly compared to other languages (not
just Python). An example:
[EMAIL PROTECTED]:~/$ date && ./compute.cpp.o < 1_million.txt > /dev/null &&
date
Thu May 15 13:08:28 EDT 2008
Thu Ma
I have some c++ binaries that do rather intense number computations.
They do it well and rather quickly compared to other languages (not just
Python). An example:
[EMAIL PROTECTED]:~/$ date && ./compute.cpp.o < 1_million.txt > /dev/null &&
date
Thu May 15 13:08:28 EDT 2008
Thu May 15 13:08:31
Hello Marco,
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> g] On Behalf Of Marco Aschwanden
> Sent: Tuesday, March 21, 2006 8:43 PM
> Subject: From Python to c++
>
> parsed = {
> "name":["Mac", "Mike
Heck! I received 1 useless answer in comp.lang.c++ and here I get useful
links/hints and even a code-pattern! Great. Thank you all.
Sorry for posting a c++-problem here, but it was derived from my thinking
the Python way...
Cheers,
Marco
--
http://mail.python.org/mailman/listinfo/python-li
On Wed, 22 Mar 2006 08:11:24 +0100, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> This is so scary, I probably shouldn't post this. It sounds from your
> description, you really want RTTI. I haven't done this in a long
> while, so I'm not sure there is an easier way. But the program below
>
Marco Aschwanden wrote:
> This is actually a c++ problem. Got no satisfying answer on comp.lang.c++.
> Maybe you can help better because I know, there are many c++-converts ;).
>
> Suppose you've got the following list (first line has field names, second
> line has types and any row after is data):
Hi Marco!
Perhaps the simpler way could be to store them all in the map as string
data, but of course, it depends on what you must do later with that
data, so you can save the field types and convert from string when
needed to use any value... if you do not need to process later that data
at a
> Any suggestions are very welcome!
Are you allowed to use any boost libraries? If so then boost::any would
probably help. The boost::any object can contain any object type. So you
could have a single container that looked like the following:
std::map< std::string, std::vector > result;
Since
On 3/21/06, Marco Aschwanden <[EMAIL PROTECTED]> wrote:
> Any suggestions are very welcome!
>
>
> Regards,
> Marco (Forced to code in c++ again let me estimate the simplicity of
> python)
C++ is also simple, if you have right library to do the job:
http://boost.org/doc/html/variant.html
http://bo
This is actually a c++ problem. Got no satisfying answer on comp.lang.c++.
Maybe you can help better because I know, there are many c++-converts ;).
Suppose you've got the following list (first line has field names, second
line has types and any row after is data):
csv = "name,age,place\nstri
47 matches
Mail list logo