Message277398
| 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 |
<1474838069.78.0.79134167582.issue11957@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年09月25日 21:14:29 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, terry.reedy, vstinner, eric.smith, ezio.melotti, eric.araujo, mrabarnett, python-dev, mindauga, mmilkin, umi |
| 2016年09月25日 21:14:29 | serhiy.storchaka | set | messageid: <1474838069.78.0.79134167582.issue11957@psf.upfronthosting.co.za> |
| 2016年09月25日 21:14:29 | serhiy.storchaka | link | issue11957 messages |
| 2016年09月25日 21:14:29 | serhiy.storchaka | create |
|