Re: python C-api and thread

2024-08-06 Thread Barry Scott via Python-list
> On 6 Aug 2024, at 07:11, aotto1968 via Python-list > wrote: > > I know but I use a thread like a process because the "conversation" between > the threads is done by my > software. a Thread is usually faster to startup (thread-pool) this mean for > high-load this is > significant faster ev

Re: python C-api and thread

2024-08-06 Thread aotto1968 via Python-list
On 06.08.24 04:34, Grant Edwards wrote: On 2024-08-05, aotto1968 via Python-list wrote: Is it possible to run two completely independent Python interpreters in one process, each using a thread? By independent, I mean that no data is shared between the interpreters and thus the C API can be us

Re: python C-api and thread (Posting On Python-List Prohibited)

2024-08-06 Thread aotto1968 via Python-list
On 06.08.24 02:32, Lawrence D'Oliveiro wrote: On Mon, 5 Aug 2024 23:19:14 +0200, aotto1968 wrote: Is it possible to run two completely independent Python interpreters in one process, each using a thread? By independent, I mean that no data is shared between the interpreters and thus the C API

Re: python C-api and thread

2024-08-05 Thread Chris Angelico via Python-list
On Tue, 6 Aug 2024 at 08:48, aotto1968 via Python-list wrote: > > hi, > > Is it possible to run two completely independent Python interpreters in one > process, each using a thread? > > By independent, I mean that no data is shared between the interpreters and > thus the C API can be used withou

Re: python C-api and thread

2024-08-05 Thread Grant Edwards via Python-list
On 2024-08-05, aotto1968 via Python-list wrote: > Is it possible to run two completely independent Python interpreters > in one process, each using a thread? > > By independent, I mean that no data is shared between the > interpreters and thus the C API can be used without any other > "lock/GIL"

python C-api and thread

2024-08-05 Thread aotto1968 via Python-list
hi, Is it possible to run two completely independent Python interpreters in one process, each using a thread? By independent, I mean that no data is shared between the interpreters and thus the C API can be used without any other "lock/GIL" etc. mfg -- https://mail.python.org/mailman/listinf

Re: Python C API: how to mark a type as subclass of another type

2021-11-02 Thread Dieter Maurer
Marco Sulla wrote at 2021-11-2 13:43 +0100: >I already added the address of the type to tp_base, but it does not work. It worked for me in `dm.incrementalsearch`. Maybe, you need a special value for `tp_flags`. Look at the examples. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: how to mark a type as subclass of another type

2021-11-02 Thread Marco Sulla
es as subclass of the other one? I tried > > >to use tp_base but it didn't work. > > > > Read the "Python/C Api" documentation. Watch out for `tp_base`. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: how to mark a type as subclass of another type

2021-11-02 Thread Marco Sulla
IT(&PyType_Type, 0) > > > >etc. > > > >How can I mark one of the types as subclass of the other one? I tried > >to use tp_base but it didn't work. > > Read the "Python/C Api" documentation. Watch out for `tp_base`. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: how to mark a type as subclass of another type

2021-11-01 Thread Dieter Maurer
Marco Sulla wrote at 2021-10-31 23:59 +0100: >I have two types declared as > >PyTypeObject PyX_Type = { >PyVarObject_HEAD_INIT(&PyType_Type, 0) > >etc. > >How can I mark one of the types as subclass of the other one? I tried >to use tp_base but it didn&

Python C API: how to mark a type as subclass of another type

2021-10-31 Thread Marco Sulla
I have two types declared as PyTypeObject PyX_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) etc. How can I mark one of the types as subclass of the other one? I tried to use tp_base but it didn't work. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 9:25 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> If you've Py_DECREFed it and then peek into its internals, you're >> aiming a gun at your foot. > > > That's true. A safer way would be to look at the refcount > *before* decreffing and verify that it's what you ex

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: If you've Py_DECREFed it and then peek into its internals, you're aiming a gun at your foot. That's true. A safer way would be to look at the refcount *before* decreffing and verify that it's what you expect. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 6:56 PM, Gregory Ewing wrote: > dieter wrote: >> >> dl l writes: >> >>> When I debug in C++, I see the reference count of a PyObject is 1. > >>> How can I find out where is referencing this object? >> >> >> Likely, it is the reference, you are holding: > > > Unless you've

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
dieter wrote: dl l writes: When I debug in C++, I see the reference count of a PyObject is 1. >> How can I find out where is referencing this object? Likely, it is the reference, you are holding: Unless you've just Py_DECREFed it, expecting it to go away, and the recfcount is still 1, in

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > When I debug in C++, I see the reference count of a PyObject is 1. I don't > know where is referencing this object. How can I find out where is > referencing this object? Likely, it is the reference, you are holding: typically, whenever you can access a Python object, this object

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > Thanks for reply. Is there any function in C to get the reference objects > of a object? I want to debug where are referencing the object. Depending on your understanding of "reference objects", this would be "gc.get_referents" or "gc.get_referrers". Of course, those are not "C"

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
a object? I want to debug where are referencing the object. > > 2016-09-27 15:01 GMT+08:00 dieter : > >> dl l writes: >> > I want to check the references of an object. Any way to get the >> references >> > of an object with Python C API? Like: gc.get_referrs(), i

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
of an object with Python C API? Like: gc.get_referrs(), is there similar > > API in C lib? > > "gc" is a module. You can import and access modules from the C API. > Thus, you can use "gc.get_referers" from "C" code. > > -- > https://mail.pytho

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dieter
dl l writes: > I want to check the references of an object. Any way to get the references > of an object with Python C API? Like: gc.get_referrs(), is there similar > API in C lib? "gc" is a module. You can import and access modules from the C API. Thus, you can use "

Python C API: How to debug reference leak?

2016-09-26 Thread dl l
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C-API: how to define nested classes?

2013-05-16 Thread Stefan Behnel
Serge WEINSTOCK, 16.05.2013 10:55: > I'm currently writing a C extension module for python using the "raw" C-API. > I would like to be able to define "nested classes" like in the following > python code > > > class A: > class B: >

Re: Python C-API: how to define nested classes?

2013-05-16 Thread 88888 Dihedral
Serge WEINSTOCK於 2013年5月16日星期四UTC+8下午4時55分07秒寫道: > Hi, > >   > > I'm currently writing a C extension module for python using the "raw" C-API. > I would like to be able to define "nested classes" like in the following > python code > >   > >

Python C-API: how to define nested classes?

2013-05-16 Thread Serge WEINSTOCK
Hi, I'm currently writing a C extension module for python using the "raw" C-API. I would like to be able to define "nested classes" like in the following python code class A: class B: def __init__(self): self.i

Re: Executing .pyc using python c api

2011-11-29 Thread 88888 Dihedral
On Tuesday, November 29, 2011 5:02:31 PM UTC+8, Ulrich Eckhardt wrote: > Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: > > I need to run .pyc files using python c api. if i do PyImport_Import it > > executes the script. However, i need to pass a set of variables and > > th

Re: Executing .pyc using python c api

2011-11-29 Thread Ulrich Eckhardt
Am 29.11.2011 08:34, schrieb Mrinalini Kulkarni: I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. I don't think wha

Re: Executing .pyc using python c api

2011-11-29 Thread Stefan Behnel
Mrinalini Kulkarni, 29.11.2011 08:34: I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. Assuming you have the source as

Executing .pyc using python c api

2011-11-29 Thread Mrinalini Kulkarni
Hi I need to run .pyc files using python c api. if i do PyImport_Import it executes the script. However, i need to pass a set of variables and their values which will be accessed from within the script. How can this be done. thanks, -- http://mail.python.org/mailman/listinfo/python-list

Re: How to dynamically create a derived type in the Python C-API

2011-11-11 Thread Ethan Furman
The question is on StackOverflow if you want to answer it directly: http://stackoverflow.com/questions/8066438 ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

How to dynamically create a derived type in the Python C-API

2011-11-11 Thread Ethan Furman
Asking on behalf of Sven Marnach: - Assume we have the type Noddy as defined in the tutorial on writing C extension modules for Python. Now we want to create a derived type, overwriting only the __new__() method of Noddy. Cur

Python - C api related - Concurrent Script Execution

2011-08-05 Thread Silver Interactive
Dear All, I have developed a C++ server application which handles requests coming in from my web server. The server application is capable of handling multiple users at a time. Each user has a session object. Each user also has some variables associated with it. These variables are maintained in t

need to extend this C code so that it initiates this python script (python C api)

2011-07-02 Thread aregee
hi i need help with extending this http://paste.pound-python.org/show/8918/ c code so that it can initiate this python script http://paste.pound-python.org/show/8917/ and export file path here.. btw I tried to run following python code : #include //changed this to python2.7/Python.h didn't work

Re: Python/C API Inheritance

2011-02-02 Thread Stefan Behnel
Евгений Почитаев, 02.02.2011 18:21: May be someone do class inheritance in Python/C API, I know how create superclass/subclass. But how I can initialize superclass from subclass initializer? struct SuperClass { PyObject_HEAD; //... }; struct SubClass { PyObject_HEAD; You need

Python/C API Inheritance

2011-02-02 Thread Евгений Почитаев
Hi to all. May be someone do class inheritance in Python/C API, I know how create superclass/subclass. But how I can initialize superclass from subclass initializer? struct SuperClass { PyObject_HEAD; //... }; struct SubClass { PyObject_HEAD; //... }; static int SubClassInit

Re: python/c api

2010-10-16 Thread Stefan Behnel
Tony, 14.10.2010 20:04: is the python/c api extensively used? and what world-famous software use it? thanks! The Sage math system makes heavy use of it, mostly through Cython. And the Python standard library has lots of modules that use it, e.g. zlib and sqlite3. You can expect that most

Re: python/c api

2010-10-16 Thread Diez B. Roggisch
alex23 writes: > On Oct 15, 5:53 am, de...@web.de (Diez B. Roggisch) wrote: >> For example Ableton Live, an audio sequencer. > > I _have_ Live and I didn't realise this :O Thanks! Well, it's not a feature for end-users, it's used internally for some midi controller mapping stuff. Our "API" so to

Re: python/c api

2010-10-14 Thread Lawrence D'Oliveiro
In message , Diez B. Roggisch wrote: > ... and a lot of embedding python into a software. Let me mention some notable Free Software that does this: Blender, GIMP and Scribus, among ones I’ve messed about with recently. Makes an amazing amount of power available. -- http://mail.python.org/mailm

Re: python/c api

2010-10-14 Thread alex23
On Oct 15, 5:53 am, de...@web.de (Diez B. Roggisch) wrote: > For example Ableton Live, an audio sequencer. I _have_ Live and I didn't realise this :O Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: python/c api

2010-10-14 Thread Diez B. Roggisch
Tony writes: > hi, > > is the python/c api extensively used? and what world-famous software > use it? thanks! It is, for a lot of extensions for python, and a lot of embedding python into a software. For example Ableton Live, an audio sequencer. Arc GIS has it, and the Eve Online.

python/c api

2010-10-14 Thread Tony
hi, is the python/c api extensively used? and what world-famous software use it? thanks! tony -- http://mail.python.org/mailman/listinfo/python-list

Creating exception class with custom fields in Python/C API

2010-06-28 Thread ty ty
And what i've missed? Or what is the right and pythonic way to define exception with custom class attributes? Thanks. (crosspost from stackoverflow: http://stackoverflow.com/questions/3118617/creating-exception-class-with-custom-fields-in-python-c-api ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Extension modules and common routines in Python/C API

2010-06-28 Thread Stefan Behnel
ty ty, 28.06.2010 08:16: I'm writing wrapper for C library. This library consist of several parts. And i want split my extension package into different extension modules. I think, this is the right way ;-) Depends. If it's somewhat large or deals with sufficiently distinct functionality, it mi

Extension modules and common routines in Python/C API

2010-06-27 Thread ty ty
ackoverflow.com/questions/3119026/extension-modules-and-common-routines-in-python-c-api ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C API, building a module

2009-11-27 Thread MRAB
P.F.C. wrote: I see what your saying. Is there another way of declaring (at least) the docstring apart from the actual array?(it would get messy otherwise) I had also tried defining the variables as static but got the same result (I thought static meant in code memory instead of the heap...?

Re: Python C API, building a module

2009-11-27 Thread MRAB
P.F.C. wrote: Hello, I'm new to the mailing list but have been using python for a while. I am now attempting to embed the interpreter into a C application but am having an issue when building a module exposing my application's functions to python. I do not know if this is the right place to as

Python C API, building a module

2009-11-27 Thread P.F.C.
Hello, I'm new to the mailing list but have been using python for a while. I am now attempting to embed the interpreter into a C application but am having an issue when building a module exposing my application's functions to python. I do not know if this is the right place to ask for help with it

Re: Python C API and references

2009-11-13 Thread Gabriel Genellina
En Thu, 12 Nov 2009 06:23:54 -0300, lallous escribió: Everytime I use PyObject_SetAttrString(obj, attr_name, py_val) and I don't need the reference to py_val I should decrement the reference after this call? If you own a reference to py_val, and you don't need it anymore, you must decremen

Re: Python C API and references

2009-11-12 Thread Mark Dickinson
On Nov 12, 9:23 am, "lallous" wrote: > Hello, > > Everytime I use PyObject_SetAttrString(obj, attr_name, py_val) and I don't > need the reference to py_val I should decrement the reference after this > call? Not necessarily: it depends where py_val came from. I find the 'ownership' model descri

Re: Python C API and references

2009-11-12 Thread lallous
Hello Daniel, Thanks for the reply. Everytime I use PyObject_SetAttrString(obj, attr_name, py_val) and I don't need the reference to py_val I should decrement the reference after this call? It really depends on /how/ the object is created. If the method used to create *py_val* increases t

Python C API and references

2009-11-12 Thread lallous
Hello, Everytime I use PyObject_SetAttrString(obj, attr_name, py_val) and I don't need the reference to py_val I should decrement the reference after this call? So for example: PyObject *py_val = PyInt_FromLong(5) PyObject_SetAttrString(py_obj, "val", py_val); Py_DECREF(py_val) Right? If s

Re: Python C api: create a new object class

2009-11-11 Thread samwyse
On Nov 10, 1:09 pm, "lallous" wrote: > Hello > > I have 3 questions, hope someone can help: > > 1) > How can I create an instance class in Python, currently I do: > > class empty: >   pass > > Then anytime I want that class (which I treat like a dictionary): > > o = empty() > o.myattr = 1 > etc...

Re: Python C api: create a new object class

2009-11-10 Thread Benjamin Peterson
lallous lgwm.org> writes: > Is there is a one line syntax to instantiate an instance? You can't instantiate an instance; it's already instantiated. > > Any other ways than this: > o = new.classobj('object', (), {}) class x: pass > How can I, similarly, create an object "o" in C api: Use PyOb

Re: Python C api: create a new object class

2009-11-10 Thread Martin v. Löwis
> How can I create an instance class in Python, currently I do: > > class empty: > pass > > Then anytime I want that class (which I treat like a dictionary): > > o = empty() > o.myattr = 1 > etc > > Is there is a one line syntax to instantiate an instance? > > Any other ways than this: >

Python C api: create a new object class

2009-11-10 Thread lallous
Hello I have 3 questions, hope someone can help: 1) How can I create an instance class in Python, currently I do: class empty: pass Then anytime I want that class (which I treat like a dictionary): o = empty() o.myattr = 1 etc Is there is a one line syntax to instantiate an instance? A

Re: Python C/API Problem

2009-09-17 Thread Gabriel Genellina
En Sat, 12 Sep 2009 07:37:18 -0300, Gianfranco Murador escribió: Ok, I solved the previous error changing the second argument , but i have another question. Does PyNode_Compile function store the object code in the file passed as argument? And it will be execute by python? I mean, it works if

Re: Python C/API Problem

2009-09-12 Thread Gianfranco Murador
Ok, I solved the previous error changing the second argument , but i have another question. Does PyNode_Compile function store the object code in the file passed as argument? And it will be execute by python? I mean, it works if i type 'python prova.pyc'? Thank. -- http://mail.python.org/mailman/l

Re: Python C/API Problem

2009-09-12 Thread Gianfranco Murador
Yes, i've done some debugging and the error is on PyParser_SimpleParseString(..) call. I'll try to change the second arguments.. Thank to all. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C/API Problem

2009-09-11 Thread Gabriel Genellina
En Fri, 11 Sep 2009 15:10:45 -0300, Gianfranco Murador escribió: int main(int argc, char *argv[]) { Py_Initialize(); struct _node *node = PyParser_SimpleParseString("from time import time,ctime\n" "print 'Today is',ctim

Re: Python C/API Problem

2009-09-11 Thread Philip Semanchuk
On Sep 11, 2009, at 2:10 PM, Gianfranco Murador wrote: Hi to all python fans, i'm trying to run this C source file: [code] #include #include #include #include #include int main(int argc, char *argv[]) { Py_Initialize(); struct _node *node = PyParser_SimpleParseString("f

Python C/API Problem

2009-09-11 Thread Gianfranco Murador
Hi to all python fans, i'm trying to run this C source file: [code] #include #include #include #include #include int main(int argc, char *argv[]) { Py_Initialize(); struct _node *node = PyParser_SimpleParseString("from time import time,ctime\n"

Re: Question to python C API

2009-04-18 Thread Wolfgang Strobl
Andreas Otto wrote about his attempts to install and run Cython: > 5. and start to build the hello world example > >I changed: print "Hello World" >to: print("Hello World")-> this is V3 AFAIK Cython doesn't support Python 3, yet. See http://trac.cython.org/c

Re: Question to python C API

2009-04-18 Thread Stefan Behnel
Andreas Otto wrote: > just my first step in Cython > > 1. download Cython-0.11.1 > > 2. read INSTALL.txt > > < > (1) Run the setup.py script in this directory > as follows: > > python setup.py install > > This will install the Pyrex package > into your Pyt

Re: Question to python C API

2009-04-17 Thread Andreas Otto
Andreas Otto wrote: > alex23 wrote: >> Did you unpack the Cython archive correctly? Is there a Shadow.py in >> your src/Cython-0.11.1/Cython/ folder? > > yes dev1...@linux02:~/ext/x86_64-suse-linux/thread/bin/Cython-0.11.1> ls -al Cython/Shadow.py -rw-r--r-- 1 dev1usr users 4130 3. Apr 10:52 Cy

Re: Question to python C API

2009-04-17 Thread Andreas Otto
alex23 wrote: > On Apr 17, 4:22 pm, Andreas Otto wrote: >> Question 1: Why you wall it "Pyrex" package ? > > From the first paragraph on the Cython site: "Cython is based on the > well-known Pyrex, but supports more cutting edge functionality and > optimizations." > >> >python ./setup.py instal

Re: Question to python C API

2009-04-17 Thread alex23
On Apr 17, 4:22 pm, Andreas Otto wrote: >         Question 1: Why you wall it "Pyrex" package ? >From the first paragraph on the Cython site: "Cython is based on the well-known Pyrex, but supports more cutting edge functionality and optimizations." > >python ./setup.py install > > Traceback (mos

Re: Question to python C API

2009-04-16 Thread Andreas Otto
Hi, just my first step in Cython 1. download Cython-0.11.1 2. read INSTALL.txt < (1) Run the setup.py script in this directory as follows: python setup.py install This will install the Pyrex package into your Python system. < Question

Re: Question to python C API

2009-04-16 Thread Stefan Behnel
Andreas Otto wrote: > the problem with such kind of framework is usually > that you start with the easy stuff and than (after a couple > of days/weeks) you come to the difficult stuff and you > have to figure out that this kind of problem does not > fit into the tool. That is a very comm

Re: Question to python C API

2009-04-16 Thread Stefan Behnel
Andreas Otto wrote: > I want to make a language binding for an existing C library > > http://libmsgque.sourceforge.net > > is this possible ? Quoting the third paragraph on Cython's homepage (i.e. the link I posted): """ This makes Cython the ideal language for wrapping external C li

Re: Question to python C API

2009-04-16 Thread Diez B. Roggisch
it is possible to write C and python code into the same file ? Not as such. And JNI is an atrocity, btw. But what you can do (if you have a pure C-API, no C++) is to completely ditch the C from the equation and go for ctypes. This allows you to easily wrap the C-functions i

Re: Interrupt Python C API

2009-04-16 Thread googler . 1 . webmaster
On 16 Apr., 11:08, Piet van Oostrum wrote: > > googler.1.webmas...@spamgourmet.com (g1w) wrote: > >g1w> hi, yes, thats true, Alan Touring told us, so it would be nice to let > >g1w> the user abort it. > >g1w> Is there a chance for windows, too? > > I don't know. I have no access to Python on W

Re: Interrupt Python C API

2009-04-16 Thread Piet van Oostrum
> googler.1.webmas...@spamgourmet.com (g1w) wrote: >g1w> hi, yes, thats true, Alan Touring told us, so it would be nice to let >g1w> the user abort it. >g1w> Is there a chance for windows, too? I don't know. I have no access to Python on Windows. Maybe there is setitimer support on Windows.

Re: Question to python C API

2009-04-16 Thread Andreas Otto
python C API is much more complex than java JNI. I don't understand why because the task is allways the same the problem is that i have a C api but don't want to use a 1 to 1 translation of the C functions to python. java generate the stub with java.h and you have to fill the

Re: Question to python C API

2009-04-16 Thread Ben Kaplan
On Apr 16, 2009, at 1:53 AM, Andreas Otto wrote: Hi, I want to make a language binding for an existing C library http://libmsgque.sourceforge.net is this possible ? -- Not only is itpossible, it's pretty common. All of the major GUI toolkits do this. Look at www.swig.org if

Re: Question to python C API

2009-04-15 Thread Andreas Otto
Hi, I want to make a language binding for an existing C library http://libmsgque.sourceforge.net is this possible ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Interrupt Python C API

2009-04-15 Thread googler . 1 . webmaster
hi, yes, thats true, Alan Touring told us, so it would be nice to let the user abort it. Is there a chance for windows, too? -- http://mail.python.org/mailman/listinfo/python-list

Re: Question to python C API

2009-04-15 Thread Stefan Behnel
Andreas Otto wrote: > I have the following question ... > > I write a custom "*.init" method and expect a variable number or arguments What's a "*.init" method? Do you mean SomeType.__init__() ? > This are my questions: > > 1.I need something like a for loop to analyse this argumen

Question to python C API

2009-04-15 Thread Andreas Otto
Hi, I have the following question ... I write a custom "*.init" method and expect a variable number or arguments This are my questions: 1.I need something like a for loop to analyse this arguments For now I try the "PyArg_ParseTupleAndKeywords" but i missing somehing

Re: Interrupt Python C API

2009-04-15 Thread Piet van Oostrum
> googler.1.webmas...@spamgourmet.com (g) wrote: >g> Hi, >g> I just have a design problem and don't know how to solve it. I call a >g> function which >g> executes a simple "PyRun_String(...)" command. >g> imagine the script while 1: pass is executed so the app would hang. Is >g> there any cha

Re: Interrupt Python C API

2009-04-14 Thread Tim Roberts
googler.1.webmas...@spamgourmet.com wrote: > >I just have a design problem and don't know how to solve it. I call a >function which >executes a simple "PyRun_String(...)" command. > >imagine the script while 1: pass is executed so the app would hang. Is >there any chance to break out this PyRun_Str

Interrupt Python C API

2009-04-14 Thread googler . 1 . webmaster
Hi, I just have a design problem and don't know how to solve it. I call a function which executes a simple "PyRun_String(...)" command. imagine the script while 1: pass is executed so the app would hang. Is there any chance to break out this PyRun_String-function? I just searched the forums for t

Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
Carl Banks writes: > On Apr 9, 11:23 pm, Hrvoje Niksic wrote: >> a...@pythoncraft.com (Aahz) writes: >> > BTW, note that if you're using Python 2.x, range(100) will cause >> > a "leak" because ints are never freed.  Instead, use xrange(). >> >> Note that using xrange() won't help with that p

Re: Python C API String Memory Consumption

2009-04-10 Thread Carl Banks
On Apr 9, 11:23 pm, Hrvoje Niksic wrote: > a...@pythoncraft.com (Aahz) writes: > > BTW, note that if you're using Python 2.x, range(100) will cause > > a "leak" because ints are never freed.  Instead, use xrange(). > > Note that using xrange() won't help with that particular problem. I think

Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
a...@pythoncraft.com (Aahz) writes: > BTW, note that if you're using Python 2.x, range(100) will cause > a "leak" because ints are never freed. Instead, use xrange(). Note that using xrange() won't help with that particular problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C API String Memory Consumption

2009-04-09 Thread Aahz
In article <41d95468-8f7a-4647-83e1-6df147744...@u8g2000yqn.googlegroups.com>, k3xji wrote: > >When I run the following function, I seem to have a mem leak, a 20 mb >of memory >is allocated and is not freed. Here is the code I run: > import esauth for i in range(100): > >... ss

Re: Python C API String Memory Consumption

2009-04-07 Thread Floris Bruynooghe
On Apr 7, 2:10 pm, John Machin wrote: > On Apr 7, 9:19 pm, MRAB wrote: > > > > > k3xji wrote: > > > Interestaing I changed malloc()/free() usage with PyMem_xx APIs and > > > the problem resolved. However, I really cannot understand why the > > > first version does not work. Here is the latest cod

Re: Python C API String Memory Consumption

2009-04-07 Thread Benjamin Peterson
Carl Banks gmail.com> writes: > However, Python apparently does leak a reference if passed a Unicode > object; PyArg_ParseTuple automatically creates an encoded string but > never decrefs it. (That might be necessary evil to preserve > compatibility, though. PyString_AS_STRING does it too.) Uni

Re: Python C API String Memory Consumption

2009-04-07 Thread John Machin
On Apr 7, 9:19 pm, MRAB wrote: > k3xji wrote: > > Interestaing I changed malloc()/free() usage with PyMem_xx APIs and > > the problem resolved. However, I really cannot understand why the > > first version does not work. Here is the latest code that has no > > problems at all: > > > static PyObjec

Re: Python C API String Memory Consumption

2009-04-07 Thread MRAB
k3xji wrote: Interestaing I changed malloc()/free() usage with PyMem_xx APIs and the problem resolved. However, I really cannot understand why the first version does not work. Here is the latest code that has no problems at all: static PyObject * penc(PyObject *self, PyObject *args) { Py

Re: Python C API String Memory Consumption

2009-04-07 Thread k3xji
Interestaing I changed malloc()/free() usage with PyMem_xx APIs and the problem resolved. However, I really cannot understand why the first version does not work. Here is the latest code that has no problems at all: static PyObject * penc(PyObject *self, PyObject *args) { PyObject * result

Re: Python C API String Memory Consumption

2009-04-07 Thread Carl Banks
On Apr 7, 12:01 am, k3xji wrote: > When I run the following function, I seem to have a mem leak, a 20 mb > of memory > is allocated and is not freed. Here is the code I run: > > >>> import esauth > >>> for i in range(100): > > ...     ss = esauth.penc('sumer') > ... > > >>> for i in range(1000

Python C API String Memory Consumption

2009-04-07 Thread k3xji
When I run the following function, I seem to have a mem leak, a 20 mb of memory is allocated and is not freed. Here is the code I run: >>> import esauth >>> for i in range(100): ... ss = esauth.penc('sumer') ... >>> for i in range(100): ... ss = esauth.penc('sumer') ... And here

Re: Python C-API Object Allocation

2009-02-24 Thread Stefan Behnel
> On Feb 21, 2009, at 10:01 AM, William Newbery wrote: >> Ive been learning the C-API lately so I can write python extensions >> for some of my c++ stuff. First thing that comes to (my) mind is that you probably do not want to write code against the bare C-API. Instead, give Cython a try. http://

Re: Python C-API Object Allocation

2009-02-23 Thread Philip Semanchuk
on PyObject_New() is probably what you want: http://docs.python.org/c-api/allocation.html FYI, there are lists specifically for the Python C API and C++ issues. I don't mean to chase you away from here; plenty of people ask C API questions here. But the other groups are helpful to know

Python C-API Object Allocation

2009-02-21 Thread William Newbery
Ive been learning the C-API lately so I can write python extensions for some of my c++ stuff. I want to use the new and delete operators for creating and destroying my objects. The problem is python seems to break it into several stages. tp_new, tp_init and tp_alloc for creation and tp_del, t

Re: Python C API (PyObject_CallMethod clear object)

2009-01-26 Thread Gabriel Genellina
En Mon, 26 Jan 2009 08:47:31 -0200, escribió: On 26 Jan., 03:25, "Gabriel Genellina" wrote: En Sun, 25 Jan 2009 23:46:01 -0200, escribió: > I have a problm with deallocating stuff. I call a function with this > command: > PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); >

Re: Python C API (PyObject_CallMethod clear object)

2009-01-26 Thread googler . 1 . webmaster
the hook is, how to delete the locals of this function, maybe thats a workaround? thanks and bye. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C API (PyObject_CallMethod clear object)

2009-01-26 Thread googler . 1 . webmaster
On 26 Jan., 03:25, "Gabriel Genellina" wrote: > En Sun, 25 Jan 2009 23:46:01 -0200,   > escribió: > > > > > I have a problm with deallocating stuff. I call a function with this > > command: > > > PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); > > > if(rvalue==NULL) > >     PyErr_

Re: Python C API (PyObject_CallMethod clear object)

2009-01-25 Thread Gabriel Genellina
En Sun, 25 Jan 2009 23:46:01 -0200, escribió: I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing h

Python C API (PyObject_CallMethod clear object)

2009-01-25 Thread googler . 1 . webmaster
Hi! I have a problm with deallocating stuff. I call a function with this command: PyObject *rvalue = PyObject_CallMethod(obj, "execute","",NULL); if(rvalue==NULL) PyErr_Print(); else Py_DECREF(rvalue); Can it be, that something is missing here? Imagine I allocate an object of a type: t

Re: Problem using python C API

2009-01-16 Thread marcglec
Right, thx for your reply, I completely overlooked "examplemodule.so" in the building step. Maybe I should sleep more these days :) Btw, I've now an other problem with PyArg_ParseTuple but I guess it is better to post in the capi-sig mailing list. Thx again, Marc. > > On Jan 16, 2009, at 5:31 AM,

  1   2   >