[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Eric V. Smith via Python-ideas
On 6/23/2023 11:34 AM, Joao S. O. Bueno wrote: On Fri, Jun 23, 2023 at 12:18 PM Eric V. Smith wrote:  On Jun 23, 2023, at 9:34 AM, Joao S. O. Bueno wrote:  On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra wrote: El jue, 22 jun 2023 a las 8:22, Randolf

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Eric V. Smith via Python-ideas
On Jun 23, 2023, at 9:34 AM, Joao S. O. Bueno wrote:On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra wrote:El jue, 22 jun 2023 a las 8:22, Randolf Scholz () escribió:Dataclasses should provide a way to ignore a type hinted attributes, and not

[Python-ideas] Re: Julia envy

2023-06-23 Thread Neal Becker
I think we can do better if we use fromiter and supply the size as count: np.fromiter ((u**2 for u in range(10)), dtype=float, count=10) On Fri, Jun 23, 2023 at 10:39 AM Joao S. O. Bueno wrote: > If you use Python's own arrays and generator expressions instead of list > comprehension (by just

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Joao S. O. Bueno
On Fri, Jun 23, 2023 at 12:18 PM Eric V. Smith wrote: >  > > On Jun 23, 2023, at 9:34 AM, Joao S. O. Bueno wrote: > >  > > > On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra > wrote: > >> >> >> El jue, 22 jun 2023 a las 8:22, Randolf Scholz () >> escribió: >> >>> Dataclasses should provide a

[Python-ideas] Re: Julia envy

2023-06-23 Thread Joao S. O. Bueno
If you use Python's own arrays and generator expressions instead of list comprehension (by just dropping the `[ ]`s), you will get each number converted to the target type in memory as soon as it is calculated. (It will be a full Python float/int instance during the calculation itself, though).

[Python-ideas] Julia envy

2023-06-23 Thread Neal Becker
One item I admire from Julia and miss in python/numpy, I often use the power of python list comprehension to process data. This data often needs to be converted to numpy for other operations, for example fancy indexing. The fact that operations using comprehensions (which produce lists) and

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Thiago Bellini Ribeiro
A possible suggestion for your problem: On strawberry-graphql we have a solution for that, by annotating the field with "strawberry.Private"[1], like this: @strawberry.type class Foo: str_attr: str str_private_attr: Private[str] That Private is defined as: Private =

[Python-ideas] Re: [dataclasses] add a NON_FIELDS sentinel after which all attributes are ignored.

2023-06-23 Thread Joao S. O. Bueno
On Fri, Jun 23, 2023 at 2:35 AM Jelle Zijlstra wrote: > > > El jue, 22 jun 2023 a las 8:22, Randolf Scholz () > escribió: > >> Dataclasses should provide a way to ignore a type hinted attributes, and >> not consider them as fields. >> >> For example, some attributes might be derived during