For the record, I encouraged this. I see no reason to amend my decision. Only .isascii(), for str, bytes, bytearray. No ascii=<bool> flags to other functions.
On Wed, Jan 31, 2018 at 4:17 AM, Serhiy Storchaka <storch...@gmail.com> wrote: > 31.01.18 13:18, INADA Naoki пише: > >> Yes. But .isascii() will be match faster than try ... >> .encode('ascii') ... except UnicodeEncodeError >> on most Python implementations. >> > > In this case this doesn't matter since this is an exceptional case, and in > any case an exception is raised for non-ascii string. > > But you are true that str.isascii() can be faster than str.encode(), and > encoding is not required for converting to int. > > Other possibility -- adding support of the boolean argument in >>> str.isdigit() >>> and similar predicates that switch them to the ASCII-only mode. Such >>> option >>> will be very useful for the str.strip(), str.split() and str.splilines() >>> methods. Currently they split using all Unicode whitespaces and line >>> separators, but there is a need to split only on ASCII whitespaces and >>> line >>> separators CR, LF and CRLF. In case of str.strip() and str.split() you >>> can >>> just pass the string of whitespace characters, but there is no such >>> option >>> for str.splilines(). >>> >>> >> It sounds good idea. Maybe, keyword only argument `ascii=False`? >> > > There is an issue for str.splilines() (don't remember the number). The > main problem was that I was not sure about an obvious argument name. > > But if revert adding str.isascii() from Python 3.7, same keyword-only >> argument should be >> added to int(), float(), decimal.Decimal(), fractions.Fraction(), >> etc... It's bit hard. >> > > Ah, it is already committed. Then I think it is too later to revert this. > I had doubts about this feature and were -0 for adding it (until we discuss > it more), but since it is added I don't see much benefit from removing it. > > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/