Re: Defining a Python enum in a C extension - am I doing this right?

2021-08-08 Thread Bartosz Golaszewski
On Fri, Aug 6, 2021 at 9:02 PM Serhiy Storchaka wrote: > > 03.08.21 13:03, Bartosz Golaszewski пише: > > Just a follow-up: this is how I did it eventually: > > I think it can be simpler. > > 1. No need to create the __main__ module. You can just create a dict. If > some attributes are required (e.

Re: Defining a Python enum in a C extension - am I doing this right?

2021-08-06 Thread Serhiy Storchaka
03.08.21 13:03, Bartosz Golaszewski пише: > Just a follow-up: this is how I did it eventually: I think it can be simpler. 1. No need to create the __main__ module. You can just create a dict. If some attributes are required (e.g. __name__) it is easy to set them in the Python code (__name__ = 'py

Re: Defining a Python enum in a C extension - am I doing this right?

2021-08-03 Thread Sean DiZazzo
On Tuesday, August 3, 2021 at 3:04:19 AM UTC-7, Bartosz Golaszewski wrote: > On Sat, Jul 31, 2021 at 3:01 PM Bartosz Golaszewski wrote: > > > > On Fri, Jul 30, 2021 at 2:41 PM Serhiy Storchaka wrote: > > > > > > 23.07.21 11:20, Bartosz Golaszewski пише: > > > > I'm working on a Python C exte

Re: Defining a Python enum in a C extension - am I doing this right?

2021-08-03 Thread Bartosz Golaszewski
On Sat, Jul 31, 2021 at 3:01 PM Bartosz Golaszewski wrote: > > On Fri, Jul 30, 2021 at 2:41 PM Serhiy Storchaka wrote: > > > > 23.07.21 11:20, Bartosz Golaszewski пише: > > > I'm working on a Python C extension and I would like to expose a > > > custom enum (as in: a class inheriting from enum.En

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-31 Thread Bartosz Golaszewski
On Fri, Jul 30, 2021 at 2:41 PM Serhiy Storchaka wrote: > > 23.07.21 11:20, Bartosz Golaszewski пише: > > I'm working on a Python C extension and I would like to expose a > > custom enum (as in: a class inheriting from enum.Enum) that would be > > entirely defined in C. > > I think that it would b

RE: Defining a Python enum in a C extension - am I doing this right?

2021-07-30 Thread Schachner, Joseph
itive Business Data -Original Message- From: Serhiy Storchaka Sent: Friday, July 30, 2021 4:22 AM To: python-list@python.org Subject: Re: Defining a Python enum in a C extension - am I doing this right? 23.07.21 11:20, Bartosz Golaszewski пише: > I'm working on a Python C extension and

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-30 Thread Serhiy Storchaka
23.07.21 11:20, Bartosz Golaszewski пише: > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. I think that it would be much easier to define it in Python, and then either import a Python

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-26 Thread Bartosz Golaszewski
On Sat, Jul 24, 2021 at 6:55 AM Dan Stromberg wrote: > > > On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski wrote: >> >> Hi! >> >> I'm working on a Python C extension and I would like to expose a >> custom enum (as in: a class inheriting from enum.Enum) that would be >> entirely defined in C.

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-23 Thread Dan Stromberg
On Fri, Jul 23, 2021 at 1:20 AM Bartosz Golaszewski wrote: > Hi! > > I'm working on a Python C extension and I would like to expose a > custom enum (as in: a class inheriting from enum.Enum) that would be > entirely defined in C. > I'm probably missing something obvious, but why would you write

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-23 Thread Bartosz Golaszewski
On Fri, Jul 23, 2021 at 5:08 PM MRAB wrote: > > On 2021-07-23 09:20, Bartosz Golaszewski wrote: > > Hi! > > > > I'm working on a Python C extension and I would like to expose a > > custom enum (as in: a class inheriting from enum.Enum) that would be > > entirely defined in C. > > > > It turned out

Re: Defining a Python enum in a C extension - am I doing this right?

2021-07-23 Thread MRAB
On 2021-07-23 09:20, Bartosz Golaszewski wrote: Hi! I'm working on a Python C extension and I would like to expose a custom enum (as in: a class inheriting from enum.Enum) that would be entirely defined in C. It turned out to not be a trivial task and the regular mechanism for inheritance using