Re: [Python-ideas] Alternative spelling for list.append()

2018-06-19 Thread Steven D'Aprano
On Mon, Jun 18, 2018 at 09:20:25PM -0400, Juancarlo Añez wrote: > >> For all practical purpose, it would be enough to define that the > >> expression: > >> > >> mylist += [item] > >> > >> gets optimized to mylist.append(item). What if mylist doesn't have an append method? Just because the variabl

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-19 Thread Steven D'Aprano
On Mon, Jun 18, 2018 at 07:23:50PM -0700, Chris Barker wrote: > Though if someone really wants to implement trig in native degrees -- more > power to 'em. > > However -- if this is really such a good idea -- wouldn't someone have make > a C lib that does it? Or has someone? Anyone looked? No, th

Re: [Python-ideas] Alternative spelling for list.append()

2018-06-19 Thread Mikhail V
On Tue, Jun 19, 2018 at 3:52 AM, Juancarlo Añez wrote: > >> The idea is to introduce new syntax for the list.append() method. >> >> >> Syntax: >> >> Variant 1. >> Use special case of index, namely omitted index: >> >> mylist[] = item > > > For all practical purpose, it would be enough to defin

[Python-ideas] POPT (Python Ob ject Provider Threads)

2018-06-19 Thread Martin Bammer
Hello, because Python is a very dynamic language the memory management is heavily used. A lot of time is used for creating (reserve memory and fill object structure with data) and destroying objects. Because of this and because of the discussions about the GIL I was wondering if there isn't a sol

Re: [Python-ideas] POPT (Python Ob ject Provider Threads)

2018-06-19 Thread Antoine Pitrou
On Tue, 19 Jun 2018 16:47:46 +0200 Martin Bammer wrote: > Hello, > > because Python is a very dynamic language the memory management is heavily > used. A lot of time is used for creating (reserve memory and fill object > structure with data) and destroying objects. Do you have numbers about that

Re: [Python-ideas] POPT (Python Ob ject Provider Threads)

2018-06-19 Thread Steven D'Aprano
On Tue, Jun 19, 2018 at 04:47:46PM +0200, Martin Bammer wrote: > And here comes the idea for POPT. With this idea the Python interpreter has > running several threads in background (1 thread for each object type) The builtins alone has 47 exception types. I hope you don't mean that each of thos

[Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-19 Thread James Edwards
I've only recently looked for these special methods, so that in and of itself may be the reason these methods aren't exposed, but I could think of objects that may wish to implement __min__ and __max__ themselves, for efficiency. For example: # A "self-sorted" list object class AlwaysSort

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-19 Thread Michael Selik
Do you mind sharing an example usage in a realistic context? There might be a good solution that doesn't require adding magic methods. On Tue, Jun 19, 2018, 12:24 PM James Edwards wrote: > I've only recently looked for these special methods, so that in and of > itself may be the reason these me

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-19 Thread Pål Grønås Drange
Well, numpy implements ndarray.min(). It would be very nice if min(np.array) worked as expected. Pål On 19 Jun 2018 21:33, "Michael Selik" wrote: > Do you mind sharing an example usage in a realistic context? There might > be a good solution that doesn't require adding magic methods. > > > On T

[Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Micheál Keane
Add a function to generator objects to copy the entire state of it: Proposed example code: game1 = complicated_game_type_thing() # Progress the game to the first decision point choices = game1.send(None) # Choose something response = get_a_response(choices) # Copy the game generator game2 = ga

Re: [Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Guido van Rossum
The state of a generator is not much more that a single Python stack frame plus an integer indicating where in the bytecode the resume point is. But copying/pickling a stack frame is complicated -- it's not just all the locals but also the try/except stack and the expression evaluation stack. Have

Re: [Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Nathaniel Smith
You might find this useful, either to use directly or as a source of inspiration: https://github.com/ll/cloudpickle-generators -n On Tue, Jun 19, 2018, 15:55 Micheál Keane wrote: > > Add a function to generator objects to copy the entire state of it: > > Proposed example code: > > game

Re: [Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Ivan Levkivskyi
> > [snip] > > As Python is being increasingly used for data science, this use case will > be increasingly common. Being able to copy generators will save a lot of > work. > > Keep in mind, I don't necessarily propose that generators should be fully > picklable; there are obviously a number of conc

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-19 Thread Steven D'Aprano
On Tue, Jun 19, 2018 at 12:33:15PM -0700, Michael Selik wrote: > Do you mind sharing an example usage in a realistic context? There might be > a good solution that doesn't require adding magic methods. You have some sort of binary search tree that is iterated over in some arbitrary order. Callin

Re: [Python-ideas] "Exposing" `__min__` and `__max__`

2018-06-19 Thread Serhiy Storchaka
19.06.18 22:18, James Edwards пише: I've only recently looked for these special methods, so that in and of itself may be the reason these methods aren't exposed, but I could think of objects that may wish to implement __min__ and __max__ themselves, for efficiency. There are two questions. 1

Re: [Python-ideas] POPT (Python Ob ject Provider Threads) (Antoine Pitrou)

2018-06-19 Thread Martin Bammer
Am 2018-06-19 um 18:00 schrieb [email protected]: Re: POPT (Python Ob ject Provider Threads) (Antoine Pitrou) Currently it's just an idea. I didn't have the time yet to create a prototype implementation. ___ Python-ideas mailing list