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 Arfrever, ezio.melotti, lemburg, martin.panter, ncoghlan, pitrou, r.david.murray, serhiy.storchaka, sjt, steven.daprano, vstinner
Date 2015-09-28.02:23:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On Sun, Sep 27, 2015 at 04:17:45PM +0000, R. David Murray wrote:
> I also want "detect if there are any surrogates".

I think that's useful enough it should be a str method. Here's a 
pure-Python implementation:

def is_surrogate(s):
    return any(0xD800 <= ord(c) <= 0xDFFF for c in s)

The actual Flexible String Representation implementation can be even 
more efficient. All-ASCII and all-Latin1 strings cannot possibly include 
surrogates, so is_surrogate will be a constant-time operation.

(If we care about making this a constant-time operation for all 
strings, the constructor could set a flag on the string object. Since 
the constructor has to walk the string anyway, I don't think that will 
cost much time-wise.)
Date User Action Args
2015-09-28 02:23:56steven.dapranosetrecipients: + steven.daprano, lemburg, ncoghlan, pitrou, vstinner, ezio.melotti, Arfrever, r.david.murray, sjt, martin.panter, serhiy.storchaka
2015-09-28 02:23:56steven.dapranolinkissue18814 messages
2015-09-28 02:23:56steven.dapranocreate