Author serhiy.storchaka
Recipients eric.araujo, eric.smith, ezio.melotti, mindauga, mmilkin, mrabarnett, python-dev, rhettinger, serhiy.storchaka, terry.reedy, umi, vstinner
Date 2016-09-25.21:14:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Here are two alternative patches. The first patch checks if count or maxsplit arguments are re.RegexFlag and raise TypeError if it is true. This makes misusing flags fail fast. The second patch deprecates passing count and maxsplit arguments as positional arguments. This imposes your to change your code (even if it is valid now) and makes hard misusing flags.

Unfortunately both ways slow down calling functions.

$ ./python -m perf timeit -s "import re" -- 're.split(":", ":a:b::c", 2)'

unpatched:                   Median +- std dev: 2.73 us +- 0.09 us
check_flags_type:            Median +- std dev: 3.74 us +- 0.09 us
deprecate_positional_count:  Median +- std dev: 10.6 us +- 0.2 us

$ ./python -m perf timeit -s "import re" -- 're.split(":", ":a:b::c", maxsplit=2)'

unpatched:                   Median +- std dev: 2.78 us +- 0.07 us
check_flags_type:            Median +- std dev: 3.75 us +- 0.10 us
deprecate_positional_count:  Median +- std dev: 2.86 us +- 0.08 us
Date User Action Args
2016-09-25 21:14:29serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, terry.reedy, vstinner, eric.smith, ezio.melotti, eric.araujo, mrabarnett, python-dev, mindauga, mmilkin, umi
2016-09-25 21:14:29serhiy.storchakasetmessageid: <>
2016-09-25 21:14:29serhiy.storchakalinkissue11957 messages
2016-09-25 21:14:29serhiy.storchakacreate