Re: How to call and execute C code in Python?

2012-05-16 Thread Barry Scott
There are many choices rather then raw python C API calls. Boost, PyCXX and ctypes are worth investigating. PyCXX requires you code in C++ but hides lots of the issues of using the Python API from you. It also supports python 2 and 3. Barry - PyCXX maintainer -- http://mail.python.org/mailma

Re: How to call and execute C code in Python?

2012-05-15 Thread Chris Angelico
On Tue, May 15, 2012 at 10:08 PM, David Shi wrote: > How to call and execute C code in Python? > > Is there any publication/documentation for this?   For the worst scenario, > how many ways are there to call and execute C codes, in Python. > > For instance, having got

How to call and execute C code in Python?

2012-05-15 Thread David Shi
How to call and execute C code in Python? Is there any publication/documentation for this?   For the worst scenario, how many ways are there to call and execute C codes, in Python. For instance, having got hold some C codes, attempting to use Python to call and execute C codes.  I.e.  Python

Re: How to call and execute C code in Python?

2012-05-14 Thread Chris Angelico
On Tue, May 15, 2012 at 12:36 AM, Michael Torrie wrote: > On 05/13/2012 11:27 AM, Mark Lawrence wrote: >> Stefan, you appear to have a lot to do with Cython. It would be polite >> to mention this when replying. > > Why?  Do you think this is some sort of weird conflict of interest?  As > anyone wh

Re: How to call and execute C code in Python?

2012-05-14 Thread Michael Torrie
On 05/13/2012 11:27 AM, Mark Lawrence wrote: > Stefan, you appear to have a lot to do with Cython. It would be polite > to mention this when replying. > Why? Do you think this is some sort of weird conflict of interest? As anyone who follows this list for several years would know, Cython is a

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Devin Jeanpierre, 14.05.2012 01:19: > Now if only my editor would bold those "cdef"s... :) Cython syntax support in editors is definitely not ubiquitous, but it's getting more and more widespread, so you may be lucky at some point (or find a way to add it yourself). Pygments also does a pretty goo

Re: How to call and execute C code in Python?

2012-05-13 Thread Devin Jeanpierre
On Sun, May 13, 2012 at 11:58 AM, Stefan Behnel wrote: > David Shi, 13.05.2012 15:25: >> Can anyone tell me how to call and exectute C code in Python? > > Take a look at Cython, a Python-like language that supports native calls to > and from C/C++ code. It translates your code i

Re: How to call and execute C code in Python?

2012-05-13 Thread Chris Angelico
On Mon, May 14, 2012 at 3:23 AM, Mark Lawrence wrote: > On 13/05/2012 16:39, Chris Angelico wrote: >> >> On Sun, May 13, 2012 at 11:25 PM, David Shi  wrote: >>> >>> Can anyone tell me how to call and exectute C code in Python? >> >> >> Browse the

Re: How to call and execute C code in Python?

2012-05-13 Thread Terry Reedy
On 5/13/2012 9:25 AM, David Shi wrote: Can anyone tell me how to call and exectute C code in Python? Regards. David *From:* "python-list-requ...@python.org" *To:* python-list@python.org *Sent:* Friday, 11 May

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 20:25: > My response to Chris Angelico was simple and > you've gone off at a complete tangent whilst writing "War and Peace". Or is > it a simple matter that my newsreader is better than your newsreader? Ah, sorry. I didn't know we were discussing at *that* level. Stefan

Re: How to call and execute C code in Python?

2012-05-13 Thread Mark Lawrence
code in Python? Browse the documentation about Extending and Embedding Python, there's an extensive API. I like your response, my first thought was to say "yes" :) It has a serious learning curve all by itself, though, with a lot of major pitfalls not only for new users. It

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:44: > On 13/05/2012 18:38, Stefan Behnel wrote: >> Mark Lawrence, 13.05.2012 19:23: >>> On 13/05/2012 16:39, Chris Angelico wrote: >>>> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >>>>> Can anyone tell

Re: How to call and execute C code in Python?

2012-05-13 Thread Mark Lawrence
On 13/05/2012 18:38, Stefan Behnel wrote: Mark Lawrence, 13.05.2012 19:23: On 13/05/2012 16:39, Chris Angelico wrote: On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: Can anyone tell me how to call and exectute C code in Python? Browse the documentation about Extending and Embedding

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:27: > On 13/05/2012 16:58, Stefan Behnel wrote: >> David Shi, 13.05.2012 15:25: >>> Can anyone tell me how to call and exectute C code in Python? >> >> Take a look at Cython, a Python-like language that supports native calls to >>

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
Mark Lawrence, 13.05.2012 19:23: > On 13/05/2012 16:39, Chris Angelico wrote: >> On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: >>> Can anyone tell me how to call and exectute C code in Python? >> >> Browse the documentation about Extending and Embedding Pytho

Re: How to call and execute C code in Python?

2012-05-13 Thread Mark Lawrence
On 13/05/2012 16:58, Stefan Behnel wrote: David Shi, 13.05.2012 15:25: Can anyone tell me how to call and exectute C code in Python? Take a look at Cython, a Python-like language that supports native calls to and from C/C++ code. It translates your code into very efficient C code, so the

Re: How to call and execute C code in Python?

2012-05-13 Thread Mark Lawrence
On 13/05/2012 16:39, Chris Angelico wrote: On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: Can anyone tell me how to call and exectute C code in Python? Browse the documentation about Extending and Embedding Python, there's an extensive API. Chris Angelico I like your respons

Re: How to call and execute C code in Python?

2012-05-13 Thread Stefan Behnel
David Shi, 13.05.2012 15:25: > Can anyone tell me how to call and exectute C code in Python? Take a look at Cython, a Python-like language that supports native calls to and from C/C++ code. It translates your code into very efficient C code, so the wrapping code tends to be very fast (of

Re: How to call and execute C code in Python?

2012-05-13 Thread Chris Angelico
On Sun, May 13, 2012 at 11:25 PM, David Shi wrote: > Can anyone tell me how to call and exectute C code in Python? Browse the documentation about Extending and Embedding Python, there's an extensive API. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

How to call and execute C code in Python?

2012-05-13 Thread David Shi
Can anyone tell me how to call and exectute C code in Python? Regards. David From: "python-list-requ...@python.org" To: python-list@python.org Sent: Friday, 11 May 2012, 5:35 Subject: Python-list Digest, Vol 104, Issue 57 - Forward

Re: How would I write this C code in Python?

2007-07-10 Thread DeveloperX
On Jul 10, 5:05 am, Bruno Desthuilliers wrote: > Mmm... We can't tell for sure since we have no use case, but I'm not > sure that the OP wants an immutable object here. > > > or an `array.array`. > > or a StringIO. > > > And is `BLOCK` > > really just a structure with *one* member? Looks a bit o

Re: How would I write this C code in Python?

2007-07-10 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit : > On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote: > >> I am trying to figure out how to rewrite the following chunk of code >> in Python: >> >> C source >> [code] >> typedef struct PF >> { >> int flags; >> long user; >> char*filename; >> unsigned ch

Re: How would I write this C code in Python?

2007-07-07 Thread Abhishek Jain
how would MAXBUFFERSIZE be taken care in python; --abhi On 7/7/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote: > Python Attempt: Please note that since I can't type TABs online > easily, I am using the @ character to represent TABs in the f

Re: How would I write this C code in Python?

2007-07-06 Thread Steven D'Aprano
On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote: > Python Attempt: Please note that since I can't type TABs online > easily, I am using the @ character to represent TABs in the following > Python code. Why not indent with spaces, just like you did for the example C code? -- Steven. --

Re: How would I write this C code in Python?

2007-07-06 Thread Marc 'BlackJack' Rintsch
On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote: > I am trying to figure out how to rewrite the following chunk of code > in Python: > > C source > [code] > typedef struct PF > { > int flags; > long user; > char*filename; > unsigned char buffer[MAXBUFFERSIZE]; > } PF; > > typedef BL

How would I write this C code in Python?

2007-07-06 Thread DeveloperX
I am trying to figure out how to rewrite the following chunk of code in Python: C source [code] typedef struct PF { int flags; long user; char*filename; unsigned char buffer[MAXBUFFERSIZE]; } PF; typedef BLOCK { PF * packdata; } BLOCK; BLOCK* blocks; [/code] My first idea was to creat

Re: C code in Python

2006-09-01 Thread Robert Kern
Tommy Grav wrote: > I have some numerical code in C that I would like to call from Python. Can > anyone point me in a direction for some text I could read on how to do this? It somewhat depends on the kind of numerical code and the interface it exposes. Do you need to pass arrays back and forth?

C code in Python

2006-09-01 Thread Tommy Grav
I have some numerical code in C that I would like to call from Python. Cananyone point me in a direction for some text I could read on how to do this?Cheers Tommy[EMAIL PROTECTED]http://homepage.mac.com/tgrav/"Any intelligent fool can make things bigger, more complex, and more violent. It takes a t