[Python-ideas] Re: Add a line_offsets() method to str

2022-06-19 Thread Jonathan Slenders
Thanks all for all the responses! That's quite a bit to think about. A couple of thoughts: 1. First, I do support a transition to UTF-8, so I understand we don't want to add more methods that deal with character offsets. (I'm familiar with how strings work in Rust.) However, does that mean we

[Python-ideas] Re: Add a line_offsets() method to str

2022-06-18 Thread Jonathan Slenders
s implementation.) > > What benchmark shows the regex to be significantly slower? > > That said, str.indexes(char) sounds like a reasonable addition. > > Best wishes, > Lucas Wiman > > On Fri, Jun 17, 2022 at 1:12 PM Jonathan Slenders > wrote: > >> Hi everyone,

[Python-ideas] Add a line_offsets() method to str

2022-06-17 Thread Jonathan Slenders
Hi everyone, Today was the 3rd time I came across a situation where it was needed to retrieve all the positions of the line endings (or beginnings) in a very long python string as efficiently as possible. First time, it was needed in prompt_toolkit, where I spent a crazy amount of time looking

[Python-ideas] Re: Regex timeouts

2022-02-14 Thread Jonathan Slenders
For what it's worth, the "regex" library on PyPI (not "re") supports timeouts: https://pypi.org/project/regex/ On Mon, Feb 14, 2022, 6:54 PM J.B. Langston wrote: > Hello, > > I had opened this bug because I had a bad regex in my code that was > causing python to hang in the regex evaluation: >

[Python-ideas] Re: Generics alternative syntax

2022-02-08 Thread Jonathan Slenders
Personally, I very much like this approach, although I'd definitely prefer <> brackets instead, like in other languages. We could possibly think of it as being syntactic sugar for the current TypeVar approach, and have it translated into TypeVars at runtime. However, if we'd define it that way,

[Python-ideas] Re: Barrier Object in asyncio lib

2021-02-26 Thread Jonathan Slenders
2021, at 08:31, Jonathan Slenders wrote: > > Barry, > > What you describe sounds like `asyncio.gather(...)` if I understand > correctly. > > The thing with a Barier is that it's usable in situations where we don't > know the other tasks. Maybe there is no reference to them from t

[Python-ideas] Re: Barrier Object in asyncio lib

2021-02-26 Thread Jonathan Slenders
guess we can probably go to bugs.python.org with this proposal.) Jonathan Le jeu. 25 févr. 2021 à 23:38, Barry Scott a écrit : > > > On 25 Feb 2021, at 17:15, Jonathan Slenders wrote: > > It does make sense to have a barrier synchronization primitive for asyncio. > T

[Python-ideas] Re: Barrier Object in asyncio lib

2021-02-25 Thread Jonathan Slenders
It does make sense to have a barrier synchronization primitive for asyncio. The idea is to make a coroutine block until at least X coroutines are waiting to enter the barrier. This is very useful, if certain actions need to be synchronized. Recently, I had to implement a barier myself for our use

Re: [Python-ideas] New PEP 550: Execution Context

2017-08-13 Thread Jonathan Slenders
For what it's worth, as part of prompt_toolkit 2.0, I implemented something very similar to Nathaniel's idea some time ago. It works pretty well, but I don't have a strong opinion against an alternative implementation. - The active context is stored as a monotonically increasing integer. - For

Re: [Python-ideas] Make partial a built-in

2016-09-20 Thread Jonathan Slenders
Le 20 sept. 2016 18:42, "Ryan Gonzalez" a écrit : > Doing something like: > > lambda x, y: myfunc(partial_arg, x, y) > > is more error-prone to changes in myfunc's signature. No, if the signature of the function changes, then the signature of the partial would also change. The