This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients 2d4d, serhiy.storchaka, steven.daprano
Date 2021-01-16.10:53:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On Sat, Jan 16, 2021 at 08:59:13AM +0000, Serhiy Storchaka wrote:
> Serhiy Storchaka <> added the comment:
> ^ matches not just the beginning of the string. It matches the 
> beginning of a line, i.e. an anchor just after '\n'.

Only in MULTILINE mode.

I completely agree that in multiline mode '^a' has to search the entire 
string. But in single line mode, if the first character isn't an 'a', 
there is no need to continue searching.

As far as I can see from the docs, ^ in single line mode and \A always 
should be constant time.

> So the original report is rejected, the behavior is expected and 
> cannot be changed. It is not a bug.

I disagree that it is expected behaviour. "Match the start of the 
string" cannot possibly match anything except the start of the string, 
so who would expect it to keep scanning past the start of the string?

(Multiline mode is, of course, different.)
Date User Action Args
2021-01-16 10:53:05steven.dapranosetrecipients: + steven.daprano, serhiy.storchaka, 2d4d
2021-01-16 10:53:05steven.dapranolinkissue42885 messages
2021-01-16 10:53:05steven.dapranocreate