Fastest way to detect a non-ASCII character in a list of strings.

Stefan Behnel stefan_ml at behnel.de
Wed Oct 20 01:52:15 EDT 2010


Dun Peal, 20.10.2010 02:07:
> On Mon, Oct 18, 2010 at 1:41 AM, Stefan Behnel wrote:
>> Or, a bit shorter, using Cython 0.13:
>>
>>     def only_allowed_characters(list strings):
>>         cdef unicode s
>>         return any((c<  31 or c>  127)
>>                    for s in strings for c in s)
>
> Very cool, this caused me to look up the 0.13 release notes:
>
> http://wiki.cython.org/ReleaseNotes-0.13
>
> So they support generator expressions inside all() et al now...

Yes, because they can be inlined with their full Python semantics.


> Makes you wonder how long till they support them generally ;-)

Well, the estimate is about one man-month, so it would be doable in about 
three months time if we had the money to work on it. So far, no one has 
made a serious offer to support that project, though.

Stefan




More information about the Python-list mailing list