~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/difflib.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
import heapq
36
36
from collections import namedtuple as _namedtuple
 
37
from functools import reduce
37
38
 
38
39
Match = _namedtuple('Match', 'a b size')
39
40
 
202
203
        #      DON'T USE!  Only __chain_b uses this.  Use isbjunk.
203
204
        # isbjunk
204
205
        #      for x in b, isbjunk(x) == isjunk(x) but much faster;
205
 
        #      it's really the has_key method of a hidden dict.
 
206
        #      it's really the __contains__ method of a hidden dict.
206
207
        #      DOES NOT WORK for x in a!
207
208
        # isbpopular
208
209
        #      for x in b, isbpopular(x) is true iff b is reasonably long
344
345
        # lot of junk in the sequence, the number of *unique* junk
345
346
        # elements is probably small.  So the memory burden of keeping
346
347
        # this dict alive is likely trivial compared to the size of b2j.
347
 
        self.isbjunk = junkdict.has_key
348
 
        self.isbpopular = populardict.has_key
 
348
        self.isbjunk = junkdict.__contains__
 
349
        self.isbpopular = populardict.__contains__
349
350
 
350
351
    def find_longest_match(self, alo, ahi, blo, bhi):
351
352
        """Find longest matching block in a[alo:ahi] and b[blo:bhi].
677
678
        # avail[x] is the number of times x appears in 'b' less the
678
679
        # number of times we've seen it in 'a' so far ... kinda
679
680
        avail = {}
680
 
        availhas, matches = avail.has_key, 0
 
681
        availhas, matches = avail.__contains__, 0
681
682
        for elt in self.a:
682
683
            if availhas(elt):
683
684
                numb = avail[elt]