Need to know if a file as only ASCII charaters
lie.1296 at gmail.com
Wed Jun 17 05:34:51 CEST 2009
Wolfgang Rohdewald wrote:
> On Wednesday, 17. June 2009, Steven D'Aprano wrote:
>> while text:
>> for c in text:
>> if c not in printable: return False
> that is one loop per character.
unless printable is a set
> wouldn't it be faster to apply a regex to text?
> something like
> while text:
> if re.search(r'\W',text): return False
regex? Don't even start...
Anyway, only cProfile and profile would know who is the fastest...
And, is speed really that important for this case? Seems like premature
optimization to me.
More information about the Python-list