performance test on python with C API interface

2024-08-20 Thread aotto1968 via Python-list
I would like to present you with a performance test where Python performs very well in relation to the NHI1 project regarding the integration of Python into C. -> results: http://thedev.nhi1.de/theLink/main/md_docs_2main_2README__PERFORMANCE.htm#README_PERFORMANCE -> project

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

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

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 > th

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 ot

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.o

Re: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-30 Thread Alan Gauld via Python-list
On 29/12/2023 01:05, Félix An via Python-list wrote: > I'm used to C# WinForms, which has an easy-to-use drag-and-drop GUI > designer in Visual Studio. Is there anything similar for Tk? How about > Qt? There are any number of them but few that work well. The best I found was Da

Re: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-29 Thread Jach Feng via Python-list
Félix An 在 2023年12月29日 星期五下午2:05:24 [UTC+13] 的信中寫道: > I'm used to C# WinForms, which has an easy-to-use drag-and-drop GUI > designer in Visual Studio. Is there anything similar for Tk? How about > Qt? What do you recommend as the easiest way to create GUI programs in > Pytho

Re: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-29 Thread Mats Wichmann via Python-list
On 12/28/23 18:05, Félix An via Python-list wrote: I'm used to C# WinForms, which has an easy-to-use drag-and-drop GUI designer in Visual Studio. Is there anything similar for Tk? How about Qt? What do you recommend as the easiest way to create GUI programs in Python, similar to the ea

RE: Subject: Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-29 Thread Greg Walters via Python-list
> I'm used to C# WinForms, which has an easy-to-use drag-and-drop GUI designer in Visual Studio. Is there anything similar for Tk? How about Qt? What do you recommend as the easiest way to create GUI programs in Python, similar to the ease of use of C# WinForms? I can't say much for

Are there any easy-to-use Visual Studio C# WinForms-like GUI designers in the Python world for Tk?

2023-12-28 Thread Félix An via Python-list
I'm used to C# WinForms, which has an easy-to-use drag-and-drop GUI designer in Visual Studio. Is there anything similar for Tk? How about Qt? What do you recommend as the easiest way to create GUI programs in Python, similar to the ease of use of C# WinForms? -- https://mail.pytho

Re: one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-27 Thread Greg Ewing via Python-list
On 28/02/23 4:24 pm, Hen Hanna wrote: is it poss. to peek at the Python-list's messages without joining ? It's mirrored to the comp.lang.python usenet group, or you can read it through gmane with a news client. -- Greg -- https://mail.python.org/mailman/listinfo/py

RE: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread avi.e.gross
don't. -Original Message- From: Python-list On Behalf Of Greg Ewing via Python-list Sent: Monday, February 27, 2023 6:49 PM To: python-list@python.org Subject: Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and On 28/02/23

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Greg Ewing via Python-list
On 28/02/23 7:40 am, avi.e.gr...@gmail.com wrote: inhahe made the point that this may not have been the original intent for python and may be a sort of bug that it is too late to fix. Guido has publically stated that it was a deliberate design choice. The merits of that design choice can be d

RE: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread avi.e.gross
hon.org Subject: Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and Op 26/02/2023 om 6:53 schreef Hen Hanna: > > There are some similarities between Python and Lisp-family > > languages, but really Python is its own thing.

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Greg Ewing via Python-list
On 27/02/23 10:07 pm, Roel Schroeven wrote: I'm guessing you're thinking about variables leaking out of list comprehensions. I seem to remember (but I could be wrong) it was a design mistake rather than a bug in the code, but in any case it's been fixed now (in the 2 to 3 transition, I think).

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Roel Schroeven
Op 27/02/2023 om 9:56 schreef inhahe: On Mon, Feb 27, 2023 at 3:52 AM Roel Schroeven wrote: > Op 26/02/2023 om 6:53 schreef Hen Hanna: > > > There are some similarities between Python and Lisp-family > > > languages, but really Python is its own thing. > > > > > > Scope (and extent ?) of

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread inhahe
On Mon, Feb 27, 2023 at 3:56 AM inhahe wrote: > > > On Mon, Feb 27, 2023 at 3:52 AM Roel Schroeven > wrote: > >> Op 26/02/2023 om 6:53 schreef Hen Hanna: >> > > There are some similarities between Python and Lisp-family >> > > languages, but really Python is its own thing. >> > >> > >> > Sco

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread inhahe
On Mon, Feb 27, 2023 at 3:52 AM Roel Schroeven wrote: > Op 26/02/2023 om 6:53 schreef Hen Hanna: > > > There are some similarities between Python and Lisp-family > > > languages, but really Python is its own thing. > > > > > > Scope (and extent ?) of variables is one reminder that Python i

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-27 Thread Roel Schroeven
Op 26/02/2023 om 6:53 schreef Hen Hanna: > There are some similarities between Python and Lisp-family > languages, but really Python is its own thing. Scope (and extent ?) of variables is one reminder that Python is not Lisp  fori in range(5):  print( i )

RE: one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-26 Thread avi.e.gross
t;> print(p2b(nested)) (1, 2, (3, 4, (5, 6, 7), 8), 9) People who speak python well do not necessarily lisp. -Original Message- From: Python-list On Behalf Of Hen Hanna Sent: Sunday, February 26, 2023 4:54 AM To: python-list@python.org Subject: Re: one Liner: Lisprint(x) --> (a,

Re: one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-26 Thread Hen Hanna
On Saturday, February 25, 2023 at 11:45:12 PM UTC-8, Hen Hanna wrote: > def Lisprint(x): print( ' (' + ', '.join(x) + ')' , '\n') > > a= ' a b c ? def f x if zero? x 0 1 ' > a += ' A B C ! just an example ' > x= a.spli

one Liner: Lisprint(x) --> (a, b, c) instead of ['a', 'b', 'c']

2023-02-26 Thread Hen Hanna
def Lisprint(x): print( ' (' + ', '.join(x) + ')' , '\n') a=' a b c ? def f x if zero? x 0 1 ' a += ' A B C ! just an example ' x= a.split() print(x) Lisprint(x) ['a', 'b', 'c', '?',

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-26 Thread Hen Hanna
On Wednesday, February 22, 2023 at 10:38:00 PM UTC-8, Greg Ewing wrote: > On 23/02/23 9:37 am, Hen Hanna wrote: > > for the first several weeks... whenever i used Python... all i could think > > ofwas this is really Lisp (inside) with a thin veil of > > Java/Pascal syntax..

Re: it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Greg Ewing via Python-list
On 23/02/23 9:37 am, Hen Hanna wrote: for the first several weeks... whenever i used Python... all i could think ofwas this is really Lisp (inside) with a thin veil of Java/Pascal syntax.. - that everything is first converted

it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and

2023-02-22 Thread Hen Hanna
it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and i'd get [Segmentation Fault] (core dumped) [Bus Error] (core dumped) [access violation] (core d

Re: C extension custom types in abi3 module

2022-12-08 Thread Robin Becker
On 08/12/2022 12:52, Robin Becker wrote: I am trying to split off reportlab C extensions to simplify installations and make use of more advanced packages. A simple extension is easily converted to being an abi3 module. However, another has a custom type which uses the old style mechanisms

C extension custom types in abi3 module

2022-12-08 Thread Robin Becker
I am trying to split off reportlab C extensions to simplify installations and make use of more advanced packages. A simple extension is easily converted to being an abi3 module. However, another has a custom type which uses the old style mechanisms here https://docs.python.org/3.7

python: setup.py: how NOT to install C extensions used only by tests

2022-11-30 Thread Bartosz Golaszewski
I have a module that has a tests/ directory which contains a C extension that's only used by test cases. I don't want to install it. I'm building it as a setuptools.Extension() added to setup() using the ext_modules argument. The test directory is not added to setup's pac

Re: Debugging Python C extensions with GDB

2022-11-15 Thread Barry
out a specific use of gdb for python c extensions. Barry > > > Nov 14, 2022, 14:32 by ba...@barrys-emacs.org: > > On 14 Nov 2022, at 19:10, Jen Kris via Python-list > wrote: > > In September 2021, Victor Stinner wrote “Debugging Python C extensions with > GDB”

Re: Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
;> In September 2021, Victor Stinner wrote “Debugging Python C extensions with >> GDB” >> (https://developers.redhat.com/articles/2021/09/08/debugging-python-c-extensions-gdb#getting_started_with_python_3_9). >> >> >> My question is: with Python 3.9+, can I

Re: Debugging Python C extensions with GDB

2022-11-14 Thread Barry
> On 14 Nov 2022, at 19:10, Jen Kris via Python-list > wrote: > > In September 2021, Victor Stinner wrote “Debugging Python C extensions with > GDB” > (https://developers.redhat.com/articles/2021/09/08/debugging-python-c-extensions-gdb#getting_started_with_python_

Debugging Python C extensions with GDB

2022-11-14 Thread Jen Kris via Python-list
In September 2021, Victor Stinner wrote “Debugging Python C extensions with GDB” (https://developers.redhat.com/articles/2021/09/08/debugging-python-c-extensions-gdb#getting_started_with_python_3_9).   My question is:  with Python 3.9+, can I debug into a C extension written in pure C and

Re: Can you mock a C function using ctypes?

2022-09-15 Thread Eryk Sun
example, Python's REPL supports a callback for reading a line from the terminal. Normally it's either hooked by a C extension, such as the readline module, or set to the default function PyOS_StdioReadline(). We can use a ctypes callback to hook into this and chain to the previou

Re: Can you mock a C function using ctypes?

2022-09-15 Thread Grant Edwards
it be "poked" into a global variable? If so, I guess it would be fairly trivial to write a dummy version of bar() in C that calls a function via a global pointer that could be set via ctypes? > ctypes function prototypes are defined by ctypes.CFUNCTYPE(restype, > *argtypes, use_errno=

Re: Can you mock a C function using ctypes?

2022-09-15 Thread Eryk Sun
On 9/15/22, Grant Edwards wrote: > > Can that be done using ctypes? > > For example, I open a library that contains functon foo() where foo() > calls external function bar() which is not contained in the library. > Then, I provide a Python bar() function that gets called by foo() when > foo() is c

Can you mock a C function using ctypes?

2022-09-15 Thread Grant Edwards
I've done unit testing of C functions using ctypes, and that works nicely until you need to provide a stub/mock function to be called by the C code under test. Can that be done using ctypes? For example, I open a library that contains functon foo() where foo() calls external function bar()

Re: How to generate a .pyi file for a C Extension using stubgen

2022-07-30 Thread Barry
gt;> https://mypy.readthedocs.io/en/stable/stubgen.html >>> >>> but the instructions about creating a stub for a C Extension are a little >>> mysterious. I tried to use it on the .so file without luck. >> >> It says that stubgen works on .py files not .so files. &

Re: How to generate a .pyi file for a C Extension using stubgen

2022-07-30 Thread Marco Sulla
On Fri, 29 Jul 2022 at 23:23, Barry wrote: > > > > > On 29 Jul 2022, at 19:33, Marco Sulla wrote: > > > > I tried to follow the instructions here: > > > > https://mypy.readthedocs.io/en/stable/stubgen.html > > > > but the instructions a

Re: How to generate a .pyi file for a C Extension using stubgen

2022-07-29 Thread Barry
> On 29 Jul 2022, at 19:33, Marco Sulla wrote: > > I tried to follow the instructions here: > > https://mypy.readthedocs.io/en/stable/stubgen.html > > but the instructions about creating a stub for a C Extension are a little > mysterious. I tried to use it on the .s

How to generate a .pyi file for a C Extension using stubgen

2022-07-29 Thread Marco Sulla
I tried to follow the instructions here: https://mypy.readthedocs.io/en/stable/stubgen.html but the instructions about creating a stub for a C Extension are a little mysterious. I tried to use it on the .so file without luck. -- https://mail.python.org/mailman/listinfo/python-list

Re: Issue sending data from C++ to Python

2022-05-19 Thread Dieter Maurer
Pablo Martinez Ulloa wrote at 2022-5-18 15:08 +0100: >I have been using your C++ Python API, in order to establish a bridge from >C++ to Python. Do you know `cython`? It can help very much in the implementation of bridges between Python and C/C++. -- https://mail.python.org/mailman/li

Re: Issue sending data from C++ to Python

2022-05-18 Thread Christian Gollwitzer
Am 18.05.22 um 16:08 schrieb Pablo Martinez Ulloa: I have been using your C++ Python API, in order to establish a bridge from C++ to Python. We want to do this, as we have a tactile sensor, which only has a library developed in C++, but we want to obtain the data in real time in Python to

Re: Issue sending data from C++ to Python

2022-05-18 Thread MRAB
On 2022-05-18 15:08, Pablo Martinez Ulloa wrote: Hello, I have been using your C++ Python API, in order to establish a bridge from C++ to Python. We want to do this, as we have a tactile sensor, which only has a library developed in C++, but we want to obtain the data in real time in Python to

Issue sending data from C++ to Python

2022-05-18 Thread Pablo Martinez Ulloa
Hello, I have been using your C++ Python API, in order to establish a bridge from C++ to Python. We want to do this, as we have a tactile sensor, which only has a library developed in C++, but we want to obtain the data in real time in Python to perform tests with a robotic arm and gripper. The

Re: Functionality like local static in C

2022-04-15 Thread Chris Angelico
On Sat, 16 Apr 2022 at 04:51, Python wrote: > > Cecil Westerhof wrote: > > In C when you declare a variable static in a function, the variable > > retains its value between function calls. > > The first time the function is called it has the default value (0 for >

Re: Functionality like local static in C

2022-04-15 Thread Python
Cecil Westerhof wrote: In C when you declare a variable static in a function, the variable retains its value between function calls. The first time the function is called it has the default value (0 for an int). But when the function changes the value in a call (for example to 43), the next time

Re: Functionality like local static in C

2022-04-15 Thread Cecil Westerhof via Python-list
Eastern. Cecil Westerhof writes: > In C when you declare a variable static in a function, the variable > retains its value between function calls. > The first time the function is called it has the default value (0 for > an int). > But when the function changes the value in a call (fo

RE: Functionality like local static in C

2022-04-14 Thread Schachner, Joseph
ential; Commercially Sensitive Business Data -Original Message- From: Cecil Westerhof Sent: Thursday, April 14, 2022 11:02 AM To: python-list@python.org Subject: Functionality like local static in C In C when you declare a variable static in a function, the variable retains its value between

Re: Functionality like local static in C

2022-04-14 Thread Chris Angelico
On Fri, 15 Apr 2022 at 03:53, Sam Ezeh wrote: > > I've seen people use function attributes for this. > ``` > Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> def function(): > ... print(function.var

Re: Functionality like local static in C

2022-04-14 Thread Dieter Maurer
Cecil Westerhof wrote at 2022-4-14 17:02 +0200: >In C when you declare a variable static in a function, the variable >retains its value between function calls. >The first time the function is called it has the default value (0 for >an int). >But when the function changes the value

Re: Functionality like local static in C

2022-04-14 Thread Joe Pfeiffer
Cecil Westerhof writes: > In C when you declare a variable static in a function, the variable > retains its value between function calls. > The first time the function is called it has the default value (0 for > an int). > But when the function changes the value in a call (fo

Re: Functionality like local static in C

2022-04-14 Thread Sam Ezeh
int(function.variable) > ... function.variable += 1 > ... > >>> function.variable = 1 > >>> function() > 1 > >>> function() > 2 > >>> > ``` > > If necessary, the variable can be initialised inside the function too. > > Kind Re

Re: Functionality like local static in C

2022-04-14 Thread Mirko via Python-list
Am 14.04.2022 um 17:02 schrieb Cecil Westerhof via Python-list: > In C when you declare a variable static in a function, the variable > retains its value between function calls. > The first time the function is called it has the default value (0 for > an int). > But when the funct

Re: Functionality like local static in C

2022-04-14 Thread Barry
> On 14 Apr 2022, at 16:28, Cecil Westerhof via Python-list > wrote: > > In C when you declare a variable static in a function, the variable > retains its value between function calls. > The first time the function is called it has the default value (0 for > an int). &g

Functionality like local static in C

2022-04-14 Thread Cecil Westerhof via Python-list
In C when you declare a variable static in a function, the variable retains its value between function calls. The first time the function is called it has the default value (0 for an int). But when the function changes the value in a call (for example to 43), the next time the function is called

Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

2022-03-21 Thread Christian Gollwitzer
Am 19.03.22 um 01:08 schrieb Ankit Agarwal: This is a very specific question. I am trying to figure out whether or not I can use pre-built python libraries and headers on Windows in a MinGW build on Linux. With the mingw cross-compiler on Linux that should be possible, however I guess it might

Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

2022-03-19 Thread Eryk Sun
On 3/18/22, Ankit Agarwal wrote: > Hi, > > This is a very specific question. I am trying to figure out whether or not > I can use pre-built python libraries and headers on Windows in a MinGW > build on Linux. Essentially I have some python and C++ code which interface > via cy

Re: Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

2022-03-19 Thread Dan Stromberg
On Fri, Mar 18, 2022 at 8:03 PM Ankit Agarwal wrote: > Hi, > > This is a very specific question. I am trying to figure out whether or not > I can use pre-built python libraries and headers on Windows in a MinGW > build on Linux. Essentially I have some python and C++ code which

Compiling and Linking pre-built Windows Python libraries with C++ files on Linux for Windows

2022-03-18 Thread Ankit Agarwal
Hi, This is a very specific question. I am trying to figure out whether or not I can use pre-built python libraries and headers on Windows in a MinGW build on Linux. Essentially I have some python and C++ code which interface via cython and pybind. I want to build a self contained C++ binary for

Re: Problem slicing a list with the C API

2022-03-12 Thread Chris Angelico
On Sun, 13 Mar 2022 at 10:41, Jen Kris wrote: > > > Thanks for PySequence_InPlaceConcat, so when I need to extend I'll know what > to use. But my previous email was based on incorrect information from > several SO posts that claimed only the extend method will work to add tuples > to a list.

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
o focus on the list pDictData itself. As I said, >> that is a list of 2-tuples, but I added each of the 2-tuples with >> PyList_Append, but you can only append a tuple to a list with the extend >> method. However, there is no append method in the C API as far as I can >>

Re: Problem slicing a list with the C API

2022-03-12 Thread Chris Angelico
d. However, there is no append method in the C API as far as I can tell > -- hence pDictData is empty. I tried with PyList_SetItem but that doesn't > work. Do you know of way to "extend" a list in the C API. > Hmm. Not entirely sure I understand the question. In Python

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
Chris, you were right to focus on the list pDictData itself.   As I said, that is a list of 2-tuples, but I added each of the 2-tuples with PyList_Append, but you can only append a tuple to a list with the extend method.  However, there is no append method in the C API as far as I can tell

Re: Problem slicing a list with the C API

2022-03-12 Thread Chris Angelico
On Sun, 13 Mar 2022 at 08:54, Jen Kris wrote: > > > pDictData, despite the name, is a list of 2-tuples where each 2-tuple is a > dictionary object and a string. > Ah, gotcha. In that case, yeah, slicing it will involve referencing the tuples all the way down the line (adding to their refcounts,

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
hat exactly is > dictdata/pDictdata? > > Have you confirmed that pDictdata (a) isn't NULL, (b) is the object > you intend it to be, and (c) contains the objects you expect it to? > The segfault might not be from the slice object itself, it might be > from actually iterating over

Re: Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
s.com: > On 2022-03-12 21:24, Jen Kris via Python-list wrote: > >> I have a C API project where I have to slice a list into two parts.   >> Unfortunately the documentation on the slice objects is not clear enough for >> me to understand how to do this, and I haven’t found e

Re: Problem slicing a list with the C API

2022-03-12 Thread Chris Angelico
with slices, so I'm a bit confused as to what's going on here. What exactly is dictdata/pDictdata? Have you confirmed that pDictdata (a) isn't NULL, (b) is the object you intend it to be, and (c) contains the objects you expect it to? The segfault might not be from the slice object it

Re: Problem slicing a list with the C API

2022-03-12 Thread MRAB
On 2022-03-12 21:24, Jen Kris via Python-list wrote: I have a C API project where I have to slice a list into two parts.   Unfortunately the documentation on the slice objects is not clear enough for me to understand how to do this, and I haven’t found enough useful info through research

Problem slicing a list with the C API

2022-03-12 Thread Jen Kris via Python-list
I have a C API project where I have to slice a list into two parts.   Unfortunately the documentation on the slice objects is not clear enough for me to understand how to do this, and I haven’t found enough useful info through research.  The list contains tuple records where each tuple consists

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
; >> Thank you MRAB for your reply. >> >> Regarding your first question, pSentence is a list.  In the nltk library, >> nltk.word_tokenize takes a string, so we convert sentence to string before >> we call nltk.word_tokenize: >> >> >>> sentence = &

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread MRAB
in(sentence) >>> pt = nltk.word_tokenize(sentence) >>> print(sentence) [ Emma by Jane Austen 1816 ] But with the C API it looks like this: PyObject *pSentence = PySequence_GetItem(pSents, sent_count); PyObject* str_sentence = PyObject_Str(pSentence); // Convert to string ; See w

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Chris Angelico
of str(sentence), not "".join(sentence). Since the join method is part of the string protocol, you'll find it here: https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_Join ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
The PyObject str_sentence is a string representation of a list.  I need to convert the list to a string like "".join because that's what the library call takes.  Mar 7, 2022, 09:09 by ros...@gmail.com: > On Tue, 8 Mar 2022 at 04:06, Jen Kris via Python-list > wrote: &g

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Chris Angelico
On Tue, 8 Mar 2022 at 04:06, Jen Kris via Python-list wrote: > But with the C API it looks like this: > > PyObject *pSentence = PySequence_GetItem(pSents, sent_count); > PyObject* str_sentence = PyObject_Str(pSentence); // Convert to string > > PyObject* repr_str = PyObject

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-07 Thread Jen Kris via Python-list
tokenize(sentence) >>> print(sentence) [ Emma by Jane Austen 1816 ] But with the C API it looks like this: PyObject *pSentence = PySequence_GetItem(pSents, sent_count); PyObject* str_sentence = PyObject_Str(pSentence);  // Convert to string ; See what str_sentence looks like: PyObject*

Re: C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-06 Thread MRAB
On 2022-03-07 00:32, Jen Kris via Python-list wrote: I am using the C API in Python 3.8 with the nltk library, and I have a problem with the return from a library call implemented with PyObject_CallFunctionObjArgs. This is the relevant Python code: import nltk from nltk.corpus import

C API PyObject_CallFunctionObjArgs returns incorrect result

2022-03-06 Thread Jen Kris via Python-list
I am using the C API in Python 3.8 with the nltk library, and I have a problem with the return from a library call implemented with PyObject_CallFunctionObjArgs.  This is the relevant Python code: import nltk from nltk.corpus import gutenberg fileids = gutenberg.fileids() sentences

Re: C is it always faster than nump?

2022-02-28 Thread Edmondo Giovannozzi
value. It just means that if a variable is changed in a procedure the changes don't propagate back to the caller. With the iso_c_binding one can directly call a C function or let a Fortran procedure appear as a C function. There is the C_LOC that gives the C address of a variable if nee

Re: C is it always faster than nump?

2022-02-26 Thread Dennis Lee Bieber
On Fri, 25 Feb 2022 21:44:14 -0800, Dan Stromberg declaimed the following: >Fortran, (still last I heard) did not support pointers, which gives Fortran >compilers the chance to exploit a very nice class of optimizations you >can't use nearly as well in languages with pointers. > Haven't l

Re: C is it always faster than nump?

2022-02-26 Thread Neil
Dan Stromberg wrote: > On Fri, Feb 25, 2022 at 8:12 AM BELAHCENE Abdelkader < > abdelkader.belahc...@enst.dz> wrote: > >> Hi, >> a lot of people think that C (or C++) is faster than python, yes I agree, >> but I think that's not the case with numpy, I belie

Re: C is it always faster than nump?

2022-02-25 Thread BELAHCENE Abdelkader
] thanks a lot Le sam. 26 févr. 2022 à 06:44, Dan Stromberg a écrit : > > On Fri, Feb 25, 2022 at 8:12 AM BELAHCENE Abdelkader < > abdelkader.belahc...@enst.dz> wrote: > >> Hi, >> a lot of people think that C (or C++) is faster than python, yes I agree, >> but I thi

Re: C is it always faster than nump?

2022-02-25 Thread Dan Stromberg
On Fri, Feb 25, 2022 at 8:12 AM BELAHCENE Abdelkader < abdelkader.belahc...@enst.dz> wrote: > Hi, > a lot of people think that C (or C++) is faster than python, yes I agree, > but I think that's not the case with numpy, I believe numpy is faster than > C, at least in som

Re: C is it always faster than nump?

2022-02-25 Thread Dan Stromberg
on may be a > tad slow. But does Python require this version of sum() or will it allow > any version that can be called the same way and returns the same results > every time? > > > > That's also true of C and pretty much every language I know of. They > define semant

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
n of sum() or will it allow any version > that can be called the same way and returns the same results every time? > That's also true of C and pretty much every language I know of. They define semantics, not implementation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
problems. -Original Message- From: Chris Angelico To: python-list@python.org Sent: Fri, Feb 25, 2022 11:16 pm Subject: Re: C is it always faster than nump? On Sat, 26 Feb 2022 at 14:35, Avi Gross via Python-list wrote: > But with numpy and more available anyway, it may not be necessary

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
Yes, Chris, C is real as a somewhat abstract concept. There are a whole slew of different variations each time it is released anew with changes and then some people at various times built actual compilers that implement a varying subset of what is possible, and not necessarily in quite the same

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 14:35, Avi Gross via Python-list wrote: > But with numpy and more available anyway, it may not be necessary to reinvent > much of that. I was just wondering if it ever made sense to simply include it > in the base python, perhaps as a second executable with a name like pyt

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
Dennis, What you describe may be a start but is it anything I might not have easily created myself? https://docs.python.org/3/library/array.html I can see creating my own object and adding those methods and attributes while gaining very little, except perhaps storage. Can I add or multiply tw

Re: C is it always faster than nump?

2022-02-25 Thread Oscar Benjamin
On Sat, 26 Feb 2022 at 03:10, Dennis Lee Bieber wrote: > > On Fri, 25 Feb 2022 23:06:57 + (UTC), Avi Gross > declaimed the following: > > >I do have to wonder if anyone ever considered adding back enough > >functionality into base Python to make some additions less needed. Is there > >any r

Re: C is it always faster than nump?

2022-02-25 Thread Dennis Lee Bieber
On Fri, 25 Feb 2022 23:06:57 + (UTC), Avi Gross declaimed the following: >I do have to wonder if anyone ever considered adding back enough functionality >into base Python to make some additions less needed. Is there any reason the >kind of structures used by so many languages cannot be made

Re: C is it always faster than nump?

2022-02-25 Thread Oscar Benjamin
M, BELAHCENE Abdelkader wrote: > >>>> Hi, > >>>> a lot of people think that C (or C++) is faster than python, yes I agree, > >>>> but I think that's not the case with numpy, I believe numpy is faster > >>>> than > >>>> C,

Re: C is it always faster than nump?

2022-02-25 Thread Barry
> On 25 Feb 2022, at 23:00, Richard Damon wrote: > > On 2/25/22 2:47 PM, Chris Angelico wrote: >>> On Sat, 26 Feb 2022 at 05:49, Richard Damon >>> wrote: >>> On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: >>>> Hi, >>>> a lot

Re: C is it always faster than nump?

2022-02-25 Thread Avi Gross via Python-list
from numpy operations into dictionaries, lists and so on, or to make graphs. If you had done the same work in a purely C (or FORTRAN or whatever environment) and had access to similar other functionality, the latter two would all be in C or some compiled library. With exceptions aplenty, sp

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 09:58, Richard Damon wrote: > > On 2/25/22 2:47 PM, Chris Angelico wrote: > > On Sat, 26 Feb 2022 at 05:49, Richard Damon > > wrote: > >> On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: > >>> Hi, > >>> a lot of people

Re: C is it always faster than nump?

2022-02-25 Thread Richard Damon
On 2/25/22 2:47 PM, Chris Angelico wrote: On Sat, 26 Feb 2022 at 05:49, Richard Damon wrote: On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: Hi, a lot of people think that C (or C++) is faster than python, yes I agree, but I think that's not the case with numpy, I believe numpy is faster

Re: C is it always faster than nump?

2022-02-25 Thread Grant Edwards
On 2022-02-25, Richard Damon wrote: > On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: >> Hi, >> a lot of people think that C (or C++) is faster than python, yes I agree, >> but I think that's not the case with numpy, I believe numpy is faster than >> C

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 06:44, Avi Gross via Python-list wrote: > > I agree with Richard. > > Some people may be confused and think c is the speed of light and > relativistically speaking, nothing can be faster. (OK, just joking. The uses > of the same letter of the alpha

Re: C is it always faster than nump?

2022-02-25 Thread Chris Angelico
On Sat, 26 Feb 2022 at 05:49, Richard Damon wrote: > > On 2/25/22 4:12 AM, BELAHCENE Abdelkader wrote: > > Hi, > > a lot of people think that C (or C++) is faster than python, yes I agree, > > but I think that's not the case with numpy, I believe numpy is faster than

  1   2   3   4   5   6   7   8   9   10   >