algorithm does python use to compare two strings
Terry Reedy
tjreedy at udel.edu
Sun Apr 29 12:34:26 EDT 2012
On 4/29/2012 6:05 AM, Terry Reedy wrote:
> On 4/29/2012 3:59 AM, J. Mwebaze wrote:
>> I am just wondering which specific algorithm does python use to compare
>> two strings.
>
> 'Python' does not use algorithms, implementations do. CPython may check
> id and or hash before doing a character-by-char comparison (or perhaps
> multiple chars at a time).
I think all the sequence comparisons check for equality of len() before
doing item by item comparison.
--
Terry Jan Reedy
More information about the Python-list
mailing list