home *** CD-ROM | disk | FTP | other *** search
Unknown | 2009-11-11 | 59.6 KB |
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was not able to be converted.
This format is not currently supported by dexvert.
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Python Compiled Bytecode (document/pythonCompiled)
| magic
| Supported |
100%
| file
| python 2.6 byte-compiled
| default
| |
99%
| file
| data
| default
| |
57%
| TrID
| CPython 2.6 bytecode
| default
| |
42%
| TrID
| Python optimized code
| default
| |
100%
| detectItEasy
| Format: Python Compiled Module(2.6a1)
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| d1 f2 0d 0a 73 f9 ee 4a | 63 00 00 00 00 00 00 00 |....s..J|c.......|
|00000010| 00 0b 00 00 00 40 00 00 | 00 73 95 01 00 00 64 00 |.....@..|.s....d.|
|00000020| 00 5a 00 00 64 01 00 64 | 02 00 64 03 00 64 04 00 |.Z..d..d|..d..d..|
|00000030| 64 05 00 64 06 00 64 07 | 00 64 08 00 64 09 00 64 |d..d..d.|.d..d..d|
|00000040| 0a 00 64 0b 00 67 0b 00 | 5a 01 00 64 0c 00 64 0d |..d..g..|Z..d..d.|
|00000050| 00 6b 02 00 5a 02 00 64 | 0c 00 64 0e 00 6b 03 00 |.k..Z..d|..d..k..|
|00000060| 6c 04 00 5a 05 00 01 64 | 0c 00 64 0f 00 6b 06 00 |l..Z...d|..d..k..|
|00000070| 6c 07 00 5a 07 00 01 65 | 05 00 64 0b 00 64 10 00 |l..Z...e|..d..d..|
|00000080| 83 02 00 5a 08 00 64 11 | 00 84 00 00 5a 09 00 64 |...Z..d.|....Z..d|
|00000090| 04 00 66 00 00 64 12 00 | 84 00 00 83 00 00 59 5a |..f..d..|......YZ|
|000000a0| 0a 00 64 13 00 64 14 00 | 64 15 00 84 02 00 5a 0b |..d..d..|d.....Z.|
|000000b0| 00 64 16 00 84 00 00 5a | 0c 00 64 05 00 66 00 00 |.d.....Z|..d..f..|
|000000c0| 64 17 00 84 00 00 83 00 | 00 59 5a 0d 00 64 0c 00 |d.......|.YZ..d..|
|000000d0| 64 0d 00 6b 0e 00 5a 0e | 00 65 0e 00 69 0f 00 64 |d..k..Z.|.e..i..d|
|000000e0| 18 00 83 01 00 69 10 00 | 64 19 00 84 01 00 5a 11 |.....i..|d.....Z.|
|000000f0| 00 64 1a 00 64 1b 00 84 | 01 00 5a 12 00 64 1c 00 |.d..d...|..Z..d..|
|00000100| 64 1c 00 64 1c 00 64 1c | 00 64 13 00 64 1d 00 64 |d..d..d.|.d..d..d|
|00000110| 1e 00 84 06 00 5a 13 00 | 64 1c 00 64 1c 00 64 1c |.....Z..|d..d..d.|
|00000120| 00 64 1c 00 64 13 00 64 | 1d 00 64 1f 00 84 06 00 |.d..d..d|..d.....|
|00000130| 5a 14 00 65 15 00 65 12 | 00 64 20 00 84 02 00 5a |Z..e..e.|.d ....Z|
|00000140| 16 00 65 15 00 65 15 00 | 65 12 00 64 21 00 84 03 |..e..e..|e..d!...|
|00000150| 00 5a 17 00 64 22 00 5a | 18 00 64 23 00 5a 19 00 |.Z..d".Z|..d#.Z..|
|00000160| 64 24 00 5a 1a 00 64 25 | 00 5a 1b 00 64 0a 00 65 |d$.Z..d%|.Z..d..e|
|00000170| 1c 00 66 01 00 64 26 00 | 84 00 00 83 00 00 59 5a |..f..d&.|......YZ|
|00000180| 1d 00 5b 0e 00 64 27 00 | 84 00 00 5a 1e 00 64 28 |..[..d'.|...Z..d(|
|00000190| 00 84 00 00 5a 1f 00 65 | 20 00 64 29 00 6a 02 00 |....Z..e| .d).j..|
|000001a0| 6f 0b 00 01 65 1f 00 83 | 00 00 01 6e 01 00 01 64 |o...e...|...n...d|
|000001b0| 0d 00 53 28 2a 00 00 00 | 73 65 03 00 00 0a 4d 6f |..S(*...|se....Mo|
|000001c0| 64 75 6c 65 20 64 69 66 | 66 6c 69 62 20 2d 2d 20 |dule dif|flib -- |
|000001d0| 68 65 6c 70 65 72 73 20 | 66 6f 72 20 63 6f 6d 70 |helpers |for comp|
|000001e0| 75 74 69 6e 67 20 64 65 | 6c 74 61 73 20 62 65 74 |uting de|ltas bet|
|000001f0| 77 65 65 6e 20 6f 62 6a | 65 63 74 73 2e 0a 0a 46 |ween obj|ects...F|
|00000200| 75 6e 63 74 69 6f 6e 20 | 67 65 74 5f 63 6c 6f 73 |unction |get_clos|
|00000210| 65 5f 6d 61 74 63 68 65 | 73 28 77 6f 72 64 2c 20 |e_matche|s(word, |
|00000220| 70 6f 73 73 69 62 69 6c | 69 74 69 65 73 2c 20 6e |possibil|ities, n|
|00000230| 3d 33 2c 20 63 75 74 6f | 66 66 3d 30 2e 36 29 3a |=3, cuto|ff=0.6):|
|00000240| 0a 20 20 20 20 55 73 65 | 20 53 65 71 75 65 6e 63 |. Use| Sequenc|
|00000250| 65 4d 61 74 63 68 65 72 | 20 74 6f 20 72 65 74 75 |eMatcher| to retu|
|00000260| 72 6e 20 6c 69 73 74 20 | 6f 66 20 74 68 65 20 62 |rn list |of the b|
|00000270| 65 73 74 20 22 67 6f 6f | 64 20 65 6e 6f 75 67 68 |est "goo|d enough|
|00000280| 22 20 6d 61 74 63 68 65 | 73 2e 0a 0a 46 75 6e 63 |" matche|s...Func|
|00000290| 74 69 6f 6e 20 63 6f 6e | 74 65 78 74 5f 64 69 66 |tion con|text_dif|
|000002a0| 66 28 61 2c 20 62 29 3a | 0a 20 20 20 20 46 6f 72 |f(a, b):|. For|
|000002b0| 20 74 77 6f 20 6c 69 73 | 74 73 20 6f 66 20 73 74 | two lis|ts of st|
|000002c0| 72 69 6e 67 73 2c 20 72 | 65 74 75 72 6e 20 61 20 |rings, r|eturn a |
|000002d0| 64 65 6c 74 61 20 69 6e | 20 63 6f 6e 74 65 78 74 |delta in| context|
|000002e0| 20 64 69 66 66 20 66 6f | 72 6d 61 74 2e 0a 0a 46 | diff fo|rmat...F|
|000002f0| 75 6e 63 74 69 6f 6e 20 | 6e 64 69 66 66 28 61 2c |unction |ndiff(a,|
|00000300| 20 62 29 3a 0a 20 20 20 | 20 52 65 74 75 72 6e 20 | b):. | Return |
|00000310| 61 20 64 65 6c 74 61 3a | 20 74 68 65 20 64 69 66 |a delta:| the dif|
|00000320| 66 65 72 65 6e 63 65 20 | 62 65 74 77 65 65 6e 20 |ference |between |
|00000330| 60 61 60 20 61 6e 64 20 | 60 62 60 20 28 6c 69 73 |`a` and |`b` (lis|
|00000340| 74 73 20 6f 66 20 73 74 | 72 69 6e 67 73 29 2e 0a |ts of st|rings)..|
|00000350| 0a 46 75 6e 63 74 69 6f | 6e 20 72 65 73 74 6f 72 |.Functio|n restor|
|00000360| 65 28 64 65 6c 74 61 2c | 20 77 68 69 63 68 29 3a |e(delta,| which):|
|00000370| 0a 20 20 20 20 52 65 74 | 75 72 6e 20 6f 6e 65 20 |. Ret|urn one |
|00000380| 6f 66 20 74 68 65 20 74 | 77 6f 20 73 65 71 75 65 |of the t|wo seque|
|00000390| 6e 63 65 73 20 74 68 61 | 74 20 67 65 6e 65 72 61 |nces tha|t genera|
|000003a0| 74 65 64 20 61 6e 20 6e | 64 69 66 66 20 64 65 6c |ted an n|diff del|
|000003b0| 74 61 2e 0a 0a 46 75 6e | 63 74 69 6f 6e 20 75 6e |ta...Fun|ction un|
|000003c0| 69 66 69 65 64 5f 64 69 | 66 66 28 61 2c 20 62 29 |ified_di|ff(a, b)|
|000003d0| 3a 0a 20 20 20 20 46 6f | 72 20 74 77 6f 20 6c 69 |:. Fo|r two li|
|000003e0| 73 74 73 20 6f 66 20 73 | 74 72 69 6e 67 73 2c 20 |sts of s|trings, |
|000003f0| 72 65 74 75 72 6e 20 61 | 20 64 65 6c 74 61 20 69 |return a| delta i|
|00000400| 6e 20 75 6e 69 66 69 65 | 64 20 64 69 66 66 20 66 |n unifie|d diff f|
|00000410| 6f 72 6d 61 74 2e 0a 0a | 43 6c 61 73 73 20 53 65 |ormat...|Class Se|
|00000420| 71 75 65 6e 63 65 4d 61 | 74 63 68 65 72 3a 0a 20 |quenceMa|tcher:. |
|00000430| 20 20 20 41 20 66 6c 65 | 78 69 62 6c 65 20 63 6c | A fle|xible cl|
|00000440| 61 73 73 20 66 6f 72 20 | 63 6f 6d 70 61 72 69 6e |ass for |comparin|
|00000450| 67 20 70 61 69 72 73 20 | 6f 66 20 73 65 71 75 65 |g pairs |of seque|
|00000460| 6e 63 65 73 20 6f 66 20 | 61 6e 79 20 74 79 70 65 |nces of |any type|
|00000470| 2e 0a 0a 43 6c 61 73 73 | 20 44 69 66 66 65 72 3a |...Class| Differ:|
|00000480| 0a 20 20 20 20 46 6f 72 | 20 70 72 6f 64 75 63 69 |. For| produci|
|00000490| 6e 67 20 68 75 6d 61 6e | 2d 72 65 61 64 61 62 6c |ng human|-readabl|
|000004a0| 65 20 64 65 6c 74 61 73 | 20 66 72 6f 6d 20 73 65 |e deltas| from se|
|000004b0| 71 75 65 6e 63 65 73 20 | 6f 66 20 6c 69 6e 65 73 |quences |of lines|
|000004c0| 20 6f 66 20 74 65 78 74 | 2e 0a 0a 43 6c 61 73 73 | of text|...Class|
|000004d0| 20 48 74 6d 6c 44 69 66 | 66 3a 0a 20 20 20 20 46 | HtmlDif|f:. F|
|000004e0| 6f 72 20 70 72 6f 64 75 | 63 69 6e 67 20 48 54 4d |or produ|cing HTM|
|000004f0| 4c 20 73 69 64 65 20 62 | 79 20 73 69 64 65 20 63 |L side b|y side c|
|00000500| 6f 6d 70 61 72 69 73 6f | 6e 20 77 69 74 68 20 63 |ompariso|n with c|
|00000510| 68 61 6e 67 65 20 68 69 | 67 68 6c 69 67 68 74 73 |hange hi|ghlights|
|00000520| 2e 0a 74 11 00 00 00 67 | 65 74 5f 63 6c 6f 73 65 |..t....g|et_close|
|00000530| 5f 6d 61 74 63 68 65 73 | 74 05 00 00 00 6e 64 69 |_matches|t....ndi|
|00000540| 66 66 74 07 00 00 00 72 | 65 73 74 6f 72 65 74 0f |fft....r|estoret.|
|00000550| 00 00 00 53 65 71 75 65 | 6e 63 65 4d 61 74 63 68 |...Seque|nceMatch|
|00000560| 65 72 74 06 00 00 00 44 | 69 66 66 65 72 74 11 00 |ert....D|iffert..|
|00000570| 00 00 49 53 5f 43 48 41 | 52 41 43 54 45 52 5f 4a |..IS_CHA|RACTER_J|
|00000580| 55 4e 4b 74 0c 00 00 00 | 49 53 5f 4c 49 4e 45 5f |UNKt....|IS_LINE_|
|00000590| 4a 55 4e 4b 74 0c 00 00 | 00 63 6f 6e 74 65 78 74 |JUNKt...|.context|
|000005a0| 5f 64 69 66 66 74 0c 00 | 00 00 75 6e 69 66 69 65 |_difft..|..unifie|
|000005b0| 64 5f 64 69 66 66 74 08 | 00 00 00 48 74 6d 6c 44 |d_difft.|...HtmlD|
|000005c0| 69 66 66 74 05 00 00 00 | 4d 61 74 63 68 69 ff ff |ifft....|Matchi..|
|000005d0| ff ff 4e 28 01 00 00 00 | 74 0a 00 00 00 6e 61 6d |..N(....|t....nam|
|000005e0| 65 64 74 75 70 6c 65 28 | 01 00 00 00 74 06 00 00 |edtuple(|....t...|
|000005f0| 00 72 65 64 75 63 65 73 | 08 00 00 00 61 20 62 20 |.reduces|....a b |
|00000600| 73 69 7a 65 63 02 00 00 | 00 02 00 00 00 02 00 00 |sizec...|........|
|00000610| 00 43 00 00 00 73 18 00 | 00 00 7c 01 00 6f 0d 00 |.C...s..|..|..o..|
|00000620| 01 64 01 00 7c 00 00 14 | 7c 01 00 15 53 01 64 02 |.d..|...||...S.d.|
|00000630| 00 53 28 03 00 00 00 4e | 67 00 00 00 00 00 00 00 |.S(....N|g.......|
|00000640| 40 67 00 00 00 00 00 00 | f0 3f 28 00 00 00 00 28 |@g......|.?(....(|
|00000650| 02 00 00 00 74 07 00 00 | 00 6d 61 74 63 68 65 73 |....t...|.matches|
|00000660| 74 06 00 00 00 6c 65 6e | 67 74 68 28 00 00 00 00 |t....len|gth(....|
|00000670| 28 00 00 00 00 73 1d 00 | 00 00 2f 75 73 72 2f 6c |(....s..|../usr/l|
|00000680| 69 62 2f 70 79 74 68 6f | 6e 32 2e 36 2f 64 69 66 |ib/pytho|n2.6/dif|
|00000690| 66 6c 69 62 2e 70 79 74 | 10 00 00 00 5f 63 61 6c |flib.pyt|...._cal|
|000006a0| 63 75 6c 61 74 65 5f 72 | 61 74 69 6f 29 00 00 00 |culate_r|atio)...|
|000006b0| 73 06 00 00 00 00 01 07 | 01 0d 01 63 00 00 00 00 |s.......|...c....|
|000006c0| 00 00 00 00 04 00 00 00 | 42 00 00 00 73 86 00 00 |........|B...s...|
|000006d0| 00 65 00 00 5a 01 00 64 | 00 00 5a 02 00 64 0f 00 |.e..Z..d|..Z..d..|
|000006e0| 64 01 00 64 01 00 64 02 | 00 84 03 00 5a 04 00 64 |d..d..d.|....Z..d|
|000006f0| 03 00 84 00 00 5a 05 00 | 64 04 00 84 00 00 5a 06 |.....Z..|d.....Z.|
|00000700| 00 64 05 00 84 00 00 5a | 07 00 64 06 00 84 00 00 |.d.....Z|..d.....|
|00000710| 5a 08 00 64 07 00 84 00 | 00 5a 09 00 64 08 00 84 |Z..d....|.Z..d...|
|00000720| 00 00 5a 0a 00 64 09 00 | 84 00 00 5a 0b 00 64 0a |..Z..d..|...Z..d.|
|00000730| 00 64 0b 00 84 01 00 5a | 0c 00 64 0c 00 84 00 00 |.d.....Z|..d.....|
|00000740| 5a 0d 00 64 0d 00 84 00 | 00 5a 0e 00 64 0e 00 84 |Z..d....|.Z..d...|
|00000750| 00 00 5a 0f 00 52 53 28 | 10 00 00 00 73 9d 10 00 |..Z..RS(|....s...|
|00000760| 00 0a 20 20 20 20 53 65 | 71 75 65 6e 63 65 4d 61 |.. Se|quenceMa|
|00000770| 74 63 68 65 72 20 69 73 | 20 61 20 66 6c 65 78 69 |tcher is| a flexi|
|00000780| 62 6c 65 20 63 6c 61 73 | 73 20 66 6f 72 20 63 6f |ble clas|s for co|
|00000790| 6d 70 61 72 69 6e 67 20 | 70 61 69 72 73 20 6f 66 |mparing |pairs of|
|000007a0| 20 73 65 71 75 65 6e 63 | 65 73 20 6f 66 0a 20 20 | sequenc|es of. |
|000007b0| 20 20 61 6e 79 20 74 79 | 70 65 2c 20 73 6f 20 6c | any ty|pe, so l|
|000007c0| 6f 6e 67 20 61 73 20 74 | 68 65 20 73 65 71 75 65 |ong as t|he seque|
|000007d0| 6e 63 65 20 65 6c 65 6d | 65 6e 74 73 20 61 72 65 |nce elem|ents are|
|000007e0| 20 68 61 73 68 61 62 6c | 65 2e 20 20 54 68 65 20 | hashabl|e. The |
|000007f0| 62 61 73 69 63 0a 20 20 | 20 20 61 6c 67 6f 72 69 |basic. | algori|
|00000800| 74 68 6d 20 70 72 65 64 | 61 74 65 73 2c 20 61 6e |thm pred|ates, an|
|00000810| 64 20 69 73 20 61 20 6c | 69 74 74 6c 65 20 66 61 |d is a l|ittle fa|
|00000820| 6e 63 69 65 72 20 74 68 | 61 6e 2c 20 61 6e 20 61 |ncier th|an, an a|
|00000830| 6c 67 6f 72 69 74 68 6d | 0a 20 20 20 20 70 75 62 |lgorithm|. pub|
|00000840| 6c 69 73 68 65 64 20 69 | 6e 20 74 68 65 20 6c 61 |lished i|n the la|
|00000850| 74 65 20 31 39 38 30 27 | 73 20 62 79 20 52 61 74 |te 1980'|s by Rat|
|00000860| 63 6c 69 66 66 20 61 6e | 64 20 4f 62 65 72 73 68 |cliff an|d Obersh|
|00000870| 65 6c 70 20 75 6e 64 65 | 72 20 74 68 65 0a 20 20 |elp unde|r the. |
|00000880| 20 20 68 79 70 65 72 62 | 6f 6c 69 63 20 6e 61 6d | hyperb|olic nam|
|00000890| 65 20 22 67 65 73 74 61 | 6c 74 20 70 61 74 74 65 |e "gesta|lt patte|
|000008a0| 72 6e 20 6d 61 74 63 68 | 69 6e 67 22 2e 20 20 54 |rn match|ing". T|
|000008b0| 68 65 20 62 61 73 69 63 | 20 69 64 65 61 20 69 73 |he basic| idea is|
|000008c0| 20 74 6f 20 66 69 6e 64 | 0a 20 20 20 20 74 68 65 | to find|. the|
|000008d0| 20 6c 6f 6e 67 65 73 74 | 20 63 6f 6e 74 69 67 75 | longest| contigu|
|000008e0| 6f 75 73 20 6d 61 74 63 | 68 69 6e 67 20 73 75 62 |ous matc|hing sub|
|000008f0| 73 65 71 75 65 6e 63 65 | 20 74 68 61 74 20 63 6f |sequence| that co|
|00000900| 6e 74 61 69 6e 73 20 6e | 6f 20 22 6a 75 6e 6b 22 |ntains n|o "junk"|
|00000910| 0a 20 20 20 20 65 6c 65 | 6d 65 6e 74 73 20 28 52 |. ele|ments (R|
|00000920| 2d 4f 20 64 6f 65 73 6e | 27 74 20 61 64 64 72 65 |-O doesn|'t addre|
|00000930| 73 73 20 6a 75 6e 6b 29 | 2e 20 20 54 68 65 20 73 |ss junk)|. The s|
|00000940| 61 6d 65 20 69 64 65 61 | 20 69 73 20 74 68 65 6e |ame idea| is then|
|00000950| 20 61 70 70 6c 69 65 64 | 0a 20 20 20 20 72 65 63 | applied|. rec|
|00000960| 75 72 73 69 76 65 6c 79 | 20 74 6f 20 74 68 65 20 |ursively| to the |
|00000970| 70 69 65 63 65 73 20 6f | 66 20 74 68 65 20 73 65 |pieces o|f the se|
|00000980| 71 75 65 6e 63 65 73 20 | 74 6f 20 74 68 65 20 6c |quences |to the l|
|00000990| 65 66 74 20 61 6e 64 20 | 74 6f 20 74 68 65 20 72 |eft and |to the r|
|000009a0| 69 67 68 74 0a 20 20 20 | 20 6f 66 20 74 68 65 20 |ight. | of the |
|000009b0| 6d 61 74 63 68 69 6e 67 | 20 73 75 62 73 65 71 75 |matching| subsequ|
|000009c0| 65 6e 63 65 2e 20 20 54 | 68 69 73 20 64 6f 65 73 |ence. T|his does|
|000009d0| 20 6e 6f 74 20 79 69 65 | 6c 64 20 6d 69 6e 69 6d | not yie|ld minim|
|000009e0| 61 6c 20 65 64 69 74 0a | 20 20 20 20 73 65 71 75 |al edit.| sequ|
|000009f0| 65 6e 63 65 73 2c 20 62 | 75 74 20 64 6f 65 73 20 |ences, b|ut does |
|00000a00| 74 65 6e 64 20 74 6f 20 | 79 69 65 6c 64 20 6d 61 |tend to |yield ma|
|00000a10| 74 63 68 65 73 20 74 68 | 61 74 20 22 6c 6f 6f 6b |tches th|at "look|
|00000a20| 20 72 69 67 68 74 22 20 | 74 6f 20 70 65 6f 70 6c | right" |to peopl|
|00000a30| 65 2e 0a 0a 20 20 20 20 | 53 65 71 75 65 6e 63 65 |e... |Sequence|
|00000a40| 4d 61 74 63 68 65 72 20 | 74 72 69 65 73 20 74 6f |Matcher |tries to|
|00000a50| 20 63 6f 6d 70 75 74 65 | 20 61 20 22 68 75 6d 61 | compute| a "huma|
|00000a60| 6e 2d 66 72 69 65 6e 64 | 6c 79 20 64 69 66 66 22 |n-friend|ly diff"|
|00000a70| 20 62 65 74 77 65 65 6e | 20 74 77 6f 0a 20 20 20 | between| two. |
|00000a80| 20 73 65 71 75 65 6e 63 | 65 73 2e 20 20 55 6e 6c | sequenc|es. Unl|
|00000a90| 69 6b 65 20 65 2e 67 2e | 20 55 4e 49 58 28 74 6d |ike e.g.| UNIX(tm|
|00000aa0| 29 20 64 69 66 66 2c 20 | 74 68 65 20 66 75 6e 64 |) diff, |the fund|
|00000ab0| 61 6d 65 6e 74 61 6c 20 | 6e 6f 74 69 6f 6e 20 69 |amental |notion i|
|00000ac0| 73 20 74 68 65 0a 20 20 | 20 20 6c 6f 6e 67 65 73 |s the. | longes|
|00000ad0| 74 20 2a 63 6f 6e 74 69 | 67 75 6f 75 73 2a 20 26 |t *conti|guous* &|
|00000ae0| 20 6a 75 6e 6b 2d 66 72 | 65 65 20 6d 61 74 63 68 | junk-fr|ee match|
|00000af0| 69 6e 67 20 73 75 62 73 | 65 71 75 65 6e 63 65 2e |ing subs|equence.|
|00000b00| 20 20 54 68 61 74 27 73 | 20 77 68 61 74 0a 20 20 | That's| what. |
|00000b10| 20 20 63 61 74 63 68 65 | 73 20 70 65 6f 70 6c 65 | catche|s people|
|00000b20| 73 27 20 65 79 65 73 2e | 20 20 54 68 65 20 57 69 |s' eyes.| The Wi|
|00000b30| 6e 64 6f 77 73 28 74 6d | 29 20 77 69 6e 64 69 66 |ndows(tm|) windif|
|00000b40| 66 20 68 61 73 20 61 6e | 6f 74 68 65 72 20 69 6e |f has an|other in|
|00000b50| 74 65 72 65 73 74 69 6e | 67 0a 20 20 20 20 6e 6f |terestin|g. no|
|00000b60| 74 69 6f 6e 2c 20 70 61 | 69 72 69 6e 67 20 75 70 |tion, pa|iring up|
|00000b70| 20 65 6c 65 6d 65 6e 74 | 73 20 74 68 61 74 20 61 | element|s that a|
|00000b80| 70 70 65 61 72 20 75 6e | 69 71 75 65 6c 79 20 69 |ppear un|iquely i|
|00000b90| 6e 20 65 61 63 68 20 73 | 65 71 75 65 6e 63 65 2e |n each s|equence.|
|00000ba0| 0a 20 20 20 20 54 68 61 | 74 2c 20 61 6e 64 20 74 |. Tha|t, and t|
|00000bb0| 68 65 20 6d 65 74 68 6f | 64 20 68 65 72 65 2c 20 |he metho|d here, |
|00000bc0| 61 70 70 65 61 72 20 74 | 6f 20 79 69 65 6c 64 20 |appear t|o yield |
|00000bd0| 6d 6f 72 65 20 69 6e 74 | 75 69 74 69 76 65 20 64 |more int|uitive d|
|00000be0| 69 66 66 65 72 65 6e 63 | 65 0a 20 20 20 20 72 65 |ifferenc|e. re|
|00000bf0| 70 6f 72 74 73 20 74 68 | 61 6e 20 64 6f 65 73 20 |ports th|an does |
|00000c00| 64 69 66 66 2e 20 20 54 | 68 69 73 20 6d 65 74 68 |diff. T|his meth|
|00000c10| 6f 64 20 61 70 70 65 61 | 72 73 20 74 6f 20 62 65 |od appea|rs to be|
|00000c20| 20 74 68 65 20 6c 65 61 | 73 74 20 76 75 6c 6e 65 | the lea|st vulne|
|00000c30| 72 61 62 6c 65 0a 20 20 | 20 20 74 6f 20 73 79 6e |rable. | to syn|
|00000c40| 63 68 69 6e 67 20 75 70 | 20 6f 6e 20 62 6c 6f 63 |ching up| on bloc|
|00000c50| 6b 73 20 6f 66 20 22 6a | 75 6e 6b 20 6c 69 6e 65 |ks of "j|unk line|
|00000c60| 73 22 2c 20 74 68 6f 75 | 67 68 20 28 6c 69 6b 65 |s", thou|gh (like|
|00000c70| 20 62 6c 61 6e 6b 20 6c | 69 6e 65 73 20 69 6e 0a | blank l|ines in.|
|00000c80| 20 20 20 20 6f 72 64 69 | 6e 61 72 79 20 74 65 78 | ordi|nary tex|
|00000c90| 74 20 66 69 6c 65 73 2c | 20 6f 72 20 6d 61 79 62 |t files,| or mayb|
|00000ca0| 65 20 22 3c 50 3e 22 20 | 6c 69 6e 65 73 20 69 6e |e "<P>" |lines in|
|00000cb0| 20 48 54 4d 4c 20 66 69 | 6c 65 73 29 2e 20 20 54 | HTML fi|les). T|
|00000cc0| 68 61 74 20 6d 61 79 20 | 62 65 0a 20 20 20 20 62 |hat may |be. b|
|00000cd0| 65 63 61 75 73 65 20 74 | 68 69 73 20 69 73 20 74 |ecause t|his is t|
|00000ce0| 68 65 20 6f 6e 6c 79 20 | 6d 65 74 68 6f 64 20 6f |he only |method o|
|00000cf0| 66 20 74 68 65 20 33 20 | 74 68 61 74 20 68 61 73 |f the 3 |that has|
|00000d00| 20 61 20 2a 63 6f 6e 63 | 65 70 74 2a 20 6f 66 0a | a *conc|ept* of.|
|00000d10| 20 20 20 20 22 6a 75 6e | 6b 22 20 3c 77 69 6e 6b | "jun|k" <wink|
|00000d20| 3e 2e 0a 0a 20 20 20 20 | 45 78 61 6d 70 6c 65 2c |>... |Example,|
|00000d30| 20 63 6f 6d 70 61 72 69 | 6e 67 20 74 77 6f 20 73 | compari|ng two s|
|00000d40| 74 72 69 6e 67 73 2c 20 | 61 6e 64 20 63 6f 6e 73 |trings, |and cons|
|00000d50| 69 64 65 72 69 6e 67 20 | 62 6c 61 6e 6b 73 20 74 |idering |blanks t|
|00000d60| 6f 20 62 65 20 22 6a 75 | 6e 6b 22 3a 0a 0a 20 20 |o be "ju|nk":.. |
|00000d70| 20 20 3e 3e 3e 20 73 20 | 3d 20 53 65 71 75 65 6e | >>> s |= Sequen|
|00000d80| 63 65 4d 61 74 63 68 65 | 72 28 6c 61 6d 62 64 61 |ceMatche|r(lambda|
|00000d90| 20 78 3a 20 78 20 3d 3d | 20 22 20 22 2c 0a 20 20 | x: x ==| " ",. |
|00000da0| 20 20 2e 2e 2e 20 20 20 | 20 20 20 20 20 20 20 20 | ... | |
|00000db0| 20 20 20 20 20 20 20 20 | 20 20 22 70 72 69 76 61 | | "priva|
|00000dc0| 74 65 20 54 68 72 65 61 | 64 20 63 75 72 72 65 6e |te Threa|d curren|
|00000dd0| 74 54 68 72 65 61 64 3b | 22 2c 0a 20 20 20 20 2e |tThread;|",. .|
|00000de0| 2e 2e 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.. | |
|00000df0| 20 20 20 20 20 20 20 22 | 70 72 69 76 61 74 65 20 | "|private |
|00000e00| 76 6f 6c 61 74 69 6c 65 | 20 54 68 72 65 61 64 20 |volatile| Thread |
|00000e10| 63 75 72 72 65 6e 74 54 | 68 72 65 61 64 3b 22 29 |currentT|hread;")|
|00000e20| 0a 20 20 20 20 3e 3e 3e | 0a 0a 20 20 20 20 2e 72 |. >>>|.. .r|
|00000e30| 61 74 69 6f 28 29 20 72 | 65 74 75 72 6e 73 20 61 |atio() r|eturns a|
|00000e40| 20 66 6c 6f 61 74 20 69 | 6e 20 5b 30 2c 20 31 5d | float i|n [0, 1]|
|00000e50| 2c 20 6d 65 61 73 75 72 | 69 6e 67 20 74 68 65 20 |, measur|ing the |
|00000e60| 22 73 69 6d 69 6c 61 72 | 69 74 79 22 20 6f 66 20 |"similar|ity" of |
|00000e70| 74 68 65 0a 20 20 20 20 | 73 65 71 75 65 6e 63 65 |the. |sequence|
|00000e80| 73 2e 20 20 41 73 20 61 | 20 72 75 6c 65 20 6f 66 |s. As a| rule of|
|00000e90| 20 74 68 75 6d 62 2c 20 | 61 20 2e 72 61 74 69 6f | thumb, |a .ratio|
|00000ea0| 28 29 20 76 61 6c 75 65 | 20 6f 76 65 72 20 30 2e |() value| over 0.|
|00000eb0| 36 20 6d 65 61 6e 73 20 | 74 68 65 0a 20 20 20 20 |6 means |the. |
|00000ec0| 73 65 71 75 65 6e 63 65 | 73 20 61 72 65 20 63 6c |sequence|s are cl|
|00000ed0| 6f 73 65 20 6d 61 74 63 | 68 65 73 3a 0a 0a 20 20 |ose matc|hes:.. |
|00000ee0| 20 20 3e 3e 3e 20 70 72 | 69 6e 74 20 72 6f 75 6e | >>> pr|int roun|
|00000ef0| 64 28 73 2e 72 61 74 69 | 6f 28 29 2c 20 33 29 0a |d(s.rati|o(), 3).|
|00000f00| 20 20 20 20 30 2e 38 36 | 36 0a 20 20 20 20 3e 3e | 0.86|6. >>|
|00000f10| 3e 0a 0a 20 20 20 20 49 | 66 20 79 6f 75 27 72 65 |>.. I|f you're|
|00000f20| 20 6f 6e 6c 79 20 69 6e | 74 65 72 65 73 74 65 64 | only in|terested|
|00000f30| 20 69 6e 20 77 68 65 72 | 65 20 74 68 65 20 73 65 | in wher|e the se|
|00000f40| 71 75 65 6e 63 65 73 20 | 6d 61 74 63 68 2c 0a 20 |quences |match,. |
|00000f50| 20 20 20 2e 67 65 74 5f | 6d 61 74 63 68 69 6e 67 | .get_|matching|
|00000f60| 5f 62 6c 6f 63 6b 73 28 | 29 20 69 73 20 68 61 6e |_blocks(|) is han|
|00000f70| 64 79 3a 0a 0a 20 20 20 | 20 3e 3e 3e 20 66 6f 72 |dy:.. | >>> for|
|00000f80| 20 62 6c 6f 63 6b 20 69 | 6e 20 73 2e 67 65 74 5f | block i|n s.get_|
|00000f90| 6d 61 74 63 68 69 6e 67 | 5f 62 6c 6f 63 6b 73 28 |matching|_blocks(|
|00000fa0| 29 3a 0a 20 20 20 20 2e | 2e 2e 20 20 20 20 20 70 |):. .|.. p|
|00000fb0| 72 69 6e 74 20 22 61 5b | 25 64 5d 20 61 6e 64 20 |rint "a[|%d] and |
|00000fc0| 62 5b 25 64 5d 20 6d 61 | 74 63 68 20 66 6f 72 20 |b[%d] ma|tch for |
|00000fd0| 25 64 20 65 6c 65 6d 65 | 6e 74 73 22 20 25 20 62 |%d eleme|nts" % b|
|00000fe0| 6c 6f 63 6b 0a 20 20 20 | 20 61 5b 30 5d 20 61 6e |lock. | a[0] an|
|00000ff0| 64 20 62 5b 30 5d 20 6d | 61 74 63 68 20 66 6f 72 |d b[0] m|atch for|
|00001000| 20 38 20 65 6c 65 6d 65 | 6e 74 73 0a 20 20 20 20 | 8 eleme|nts. |
|00001010| 61 5b 38 5d 20 61 6e 64 | 20 62 5b 31 37 5d 20 6d |a[8] and| b[17] m|
|00001020| 61 74 63 68 20 66 6f 72 | 20 32 31 20 65 6c 65 6d |atch for| 21 elem|
|00001030| 65 6e 74 73 0a 20 20 20 | 20 61 5b 32 39 5d 20 61 |ents. | a[29] a|
|00001040| 6e 64 20 62 5b 33 38 5d | 20 6d 61 74 63 68 20 66 |nd b[38]| match f|
|00001050| 6f 72 20 30 20 65 6c 65 | 6d 65 6e 74 73 0a 0a 20 |or 0 ele|ments.. |
|00001060| 20 20 20 4e 6f 74 65 20 | 74 68 61 74 20 74 68 65 | Note |that the|
|00001070| 20 6c 61 73 74 20 74 75 | 70 6c 65 20 72 65 74 75 | last tu|ple retu|
|00001080| 72 6e 65 64 20 62 79 20 | 2e 67 65 74 5f 6d 61 74 |rned by |.get_mat|
|00001090| 63 68 69 6e 67 5f 62 6c | 6f 63 6b 73 28 29 20 69 |ching_bl|ocks() i|
|000010a0| 73 20 61 6c 77 61 79 73 | 20 61 0a 20 20 20 20 64 |s always| a. d|
|000010b0| 75 6d 6d 79 2c 20 28 6c | 65 6e 28 61 29 2c 20 6c |ummy, (l|en(a), l|
|000010c0| 65 6e 28 62 29 2c 20 30 | 29 2c 20 61 6e 64 20 74 |en(b), 0|), and t|
|000010d0| 68 69 73 20 69 73 20 74 | 68 65 20 6f 6e 6c 79 20 |his is t|he only |
|000010e0| 63 61 73 65 20 69 6e 20 | 77 68 69 63 68 20 74 68 |case in |which th|
|000010f0| 65 20 6c 61 73 74 0a 20 | 20 20 20 74 75 70 6c 65 |e last. | tuple|
|00001100| 20 65 6c 65 6d 65 6e 74 | 20 28 6e 75 6d 62 65 72 | element| (number|
|00001110| 20 6f 66 20 65 6c 65 6d | 65 6e 74 73 20 6d 61 74 | of elem|ents mat|
|00001120| 63 68 65 64 29 20 69 73 | 20 30 2e 0a 0a 20 20 20 |ched) is| 0... |
|00001130| 20 49 66 20 79 6f 75 20 | 77 61 6e 74 20 74 6f 20 | If you |want to |
|00001140| 6b 6e 6f 77 20 68 6f 77 | 20 74 6f 20 63 68 61 6e |know how| to chan|
|00001150| 67 65 20 74 68 65 20 66 | 69 72 73 74 20 73 65 71 |ge the f|irst seq|
|00001160| 75 65 6e 63 65 20 69 6e | 74 6f 20 74 68 65 20 73 |uence in|to the s|
|00001170| 65 63 6f 6e 64 2c 0a 20 | 20 20 20 75 73 65 20 2e |econd,. | use .|
|00001180| 67 65 74 5f 6f 70 63 6f | 64 65 73 28 29 3a 0a 0a |get_opco|des():..|
|00001190| 20 20 20 20 3e 3e 3e 20 | 66 6f 72 20 6f 70 63 6f | >>> |for opco|
|000011a0| 64 65 20 69 6e 20 73 2e | 67 65 74 5f 6f 70 63 6f |de in s.|get_opco|
|000011b0| 64 65 73 28 29 3a 0a 20 | 20 20 20 2e 2e 2e 20 20 |des():. | ... |
|000011c0| 20 20 20 70 72 69 6e 74 | 20 22 25 36 73 20 61 5b | print| "%6s a[|
|000011d0| 25 64 3a 25 64 5d 20 62 | 5b 25 64 3a 25 64 5d 22 |%d:%d] b|[%d:%d]"|
|000011e0| 20 25 20 6f 70 63 6f 64 | 65 0a 20 20 20 20 20 65 | % opcod|e. e|
|000011f0| 71 75 61 6c 20 61 5b 30 | 3a 38 5d 20 62 5b 30 3a |qual a[0|:8] b[0:|
|00001200| 38 5d 0a 20 20 20 20 69 | 6e 73 65 72 74 20 61 5b |8]. i|nsert a[|
|00001210| 38 3a 38 5d 20 62 5b 38 | 3a 31 37 5d 0a 20 20 20 |8:8] b[8|:17]. |
|00001220| 20 20 65 71 75 61 6c 20 | 61 5b 38 3a 32 39 5d 20 | equal |a[8:29] |
|00001230| 62 5b 31 37 3a 33 38 5d | 0a 0a 20 20 20 20 53 65 |b[17:38]|.. Se|
|00001240| 65 20 74 68 65 20 44 69 | 66 66 65 72 20 63 6c 61 |e the Di|ffer cla|
|00001250| 73 73 20 66 6f 72 20 61 | 20 66 61 6e 63 79 20 68 |ss for a| fancy h|
|00001260| 75 6d 61 6e 2d 66 72 69 | 65 6e 64 6c 79 20 66 69 |uman-fri|endly fi|
|00001270| 6c 65 20 64 69 66 66 65 | 72 65 6e 63 65 72 2c 20 |le diffe|rencer, |
|00001280| 77 68 69 63 68 0a 20 20 | 20 20 75 73 65 73 20 53 |which. | uses S|
|00001290| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 20 62 |equenceM|atcher b|
|000012a0| 6f 74 68 20 74 6f 20 63 | 6f 6d 70 61 72 65 20 73 |oth to c|ompare s|
|000012b0| 65 71 75 65 6e 63 65 73 | 20 6f 66 20 6c 69 6e 65 |equences| of line|
|000012c0| 73 2c 20 61 6e 64 20 74 | 6f 20 63 6f 6d 70 61 72 |s, and t|o compar|
|000012d0| 65 0a 20 20 20 20 73 65 | 71 75 65 6e 63 65 73 20 |e. se|quences |
|000012e0| 6f 66 20 63 68 61 72 61 | 63 74 65 72 73 20 77 69 |of chara|cters wi|
|000012f0| 74 68 69 6e 20 73 69 6d | 69 6c 61 72 20 28 6e 65 |thin sim|ilar (ne|
|00001300| 61 72 2d 6d 61 74 63 68 | 69 6e 67 29 20 6c 69 6e |ar-match|ing) lin|
|00001310| 65 73 2e 0a 0a 20 20 20 | 20 53 65 65 20 61 6c 73 |es... | See als|
|00001320| 6f 20 66 75 6e 63 74 69 | 6f 6e 20 67 65 74 5f 63 |o functi|on get_c|
|00001330| 6c 6f 73 65 5f 6d 61 74 | 63 68 65 73 28 29 20 69 |lose_mat|ches() i|
|00001340| 6e 20 74 68 69 73 20 6d | 6f 64 75 6c 65 2c 20 77 |n this m|odule, w|
|00001350| 68 69 63 68 20 73 68 6f | 77 73 20 68 6f 77 0a 20 |hich sho|ws how. |
|00001360| 20 20 20 73 69 6d 70 6c | 65 20 63 6f 64 65 20 62 | simpl|e code b|
|00001370| 75 69 6c 64 69 6e 67 20 | 6f 6e 20 53 65 71 75 65 |uilding |on Seque|
|00001380| 6e 63 65 4d 61 74 63 68 | 65 72 20 63 61 6e 20 62 |nceMatch|er can b|
|00001390| 65 20 75 73 65 64 20 74 | 6f 20 64 6f 20 75 73 65 |e used t|o do use|
|000013a0| 66 75 6c 20 77 6f 72 6b | 2e 0a 0a 20 20 20 20 54 |ful work|... T|
|000013b0| 69 6d 69 6e 67 3a 20 20 | 42 61 73 69 63 20 52 2d |iming: |Basic R-|
|000013c0| 4f 20 69 73 20 63 75 62 | 69 63 20 74 69 6d 65 20 |O is cub|ic time |
|000013d0| 77 6f 72 73 74 20 63 61 | 73 65 20 61 6e 64 20 71 |worst ca|se and q|
|000013e0| 75 61 64 72 61 74 69 63 | 20 74 69 6d 65 20 65 78 |uadratic| time ex|
|000013f0| 70 65 63 74 65 64 0a 20 | 20 20 20 63 61 73 65 2e |pected. | case.|
|00001400| 20 20 53 65 71 75 65 6e | 63 65 4d 61 74 63 68 65 | Sequen|ceMatche|
|00001410| 72 20 69 73 20 71 75 61 | 64 72 61 74 69 63 20 74 |r is qua|dratic t|
|00001420| 69 6d 65 20 66 6f 72 20 | 74 68 65 20 77 6f 72 73 |ime for |the wors|
|00001430| 74 20 63 61 73 65 20 61 | 6e 64 20 68 61 73 0a 20 |t case a|nd has. |
|00001440| 20 20 20 65 78 70 65 63 | 74 65 64 2d 63 61 73 65 | expec|ted-case|
|00001450| 20 62 65 68 61 76 69 6f | 72 20 64 65 70 65 6e 64 | behavio|r depend|
|00001460| 65 6e 74 20 69 6e 20 61 | 20 63 6f 6d 70 6c 69 63 |ent in a| complic|
|00001470| 61 74 65 64 20 77 61 79 | 20 6f 6e 20 68 6f 77 20 |ated way| on how |
|00001480| 6d 61 6e 79 0a 20 20 20 | 20 65 6c 65 6d 65 6e 74 |many. | element|
|00001490| 73 20 74 68 65 20 73 65 | 71 75 65 6e 63 65 73 20 |s the se|quences |
|000014a0| 68 61 76 65 20 69 6e 20 | 63 6f 6d 6d 6f 6e 3b 20 |have in |common; |
|000014b0| 62 65 73 74 20 63 61 73 | 65 20 74 69 6d 65 20 69 |best cas|e time i|
|000014c0| 73 20 6c 69 6e 65 61 72 | 2e 0a 0a 20 20 20 20 4d |s linear|... M|
|000014d0| 65 74 68 6f 64 73 3a 0a | 0a 20 20 20 20 5f 5f 69 |ethods:.|. __i|
|000014e0| 6e 69 74 5f 5f 28 69 73 | 6a 75 6e 6b 3d 4e 6f 6e |nit__(is|junk=Non|
|000014f0| 65 2c 20 61 3d 27 27 2c | 20 62 3d 27 27 29 0a 20 |e, a='',| b=''). |
|00001500| 20 20 20 20 20 20 20 43 | 6f 6e 73 74 72 75 63 74 | C|onstruct|
|00001510| 20 61 20 53 65 71 75 65 | 6e 63 65 4d 61 74 63 68 | a Seque|nceMatch|
|00001520| 65 72 2e 0a 0a 20 20 20 | 20 73 65 74 5f 73 65 71 |er... | set_seq|
|00001530| 73 28 61 2c 20 62 29 0a | 20 20 20 20 20 20 20 20 |s(a, b).| |
|00001540| 53 65 74 20 74 68 65 20 | 74 77 6f 20 73 65 71 75 |Set the |two sequ|
|00001550| 65 6e 63 65 73 20 74 6f | 20 62 65 20 63 6f 6d 70 |ences to| be comp|
|00001560| 61 72 65 64 2e 0a 0a 20 | 20 20 20 73 65 74 5f 73 |ared... | set_s|
|00001570| 65 71 31 28 61 29 0a 20 | 20 20 20 20 20 20 20 53 |eq1(a). | S|
|00001580| 65 74 20 74 68 65 20 66 | 69 72 73 74 20 73 65 71 |et the f|irst seq|
|00001590| 75 65 6e 63 65 20 74 6f | 20 62 65 20 63 6f 6d 70 |uence to| be comp|
|000015a0| 61 72 65 64 2e 0a 0a 20 | 20 20 20 73 65 74 5f 73 |ared... | set_s|
|000015b0| 65 71 32 28 62 29 0a 20 | 20 20 20 20 20 20 20 53 |eq2(b). | S|
|000015c0| 65 74 20 74 68 65 20 73 | 65 63 6f 6e 64 20 73 65 |et the s|econd se|
|000015d0| 71 75 65 6e 63 65 20 74 | 6f 20 62 65 20 63 6f 6d |quence t|o be com|
|000015e0| 70 61 72 65 64 2e 0a 0a | 20 20 20 20 66 69 6e 64 |pared...| find|
|000015f0| 5f 6c 6f 6e 67 65 73 74 | 5f 6d 61 74 63 68 28 61 |_longest|_match(a|
|00001600| 6c 6f 2c 20 61 68 69 2c | 20 62 6c 6f 2c 20 62 68 |lo, ahi,| blo, bh|
|00001610| 69 29 0a 20 20 20 20 20 | 20 20 20 46 69 6e 64 20 |i). | Find |
|00001620| 6c 6f 6e 67 65 73 74 20 | 6d 61 74 63 68 69 6e 67 |longest |matching|
|00001630| 20 62 6c 6f 63 6b 20 69 | 6e 20 61 5b 61 6c 6f 3a | block i|n a[alo:|
|00001640| 61 68 69 5d 20 61 6e 64 | 20 62 5b 62 6c 6f 3a 62 |ahi] and| b[blo:b|
|00001650| 68 69 5d 2e 0a 0a 20 20 | 20 20 67 65 74 5f 6d 61 |hi]... | get_ma|
|00001660| 74 63 68 69 6e 67 5f 62 | 6c 6f 63 6b 73 28 29 0a |tching_b|locks().|
|00001670| 20 20 20 20 20 20 20 20 | 52 65 74 75 72 6e 20 6c | |Return l|
|00001680| 69 73 74 20 6f 66 20 74 | 72 69 70 6c 65 73 20 64 |ist of t|riples d|
|00001690| 65 73 63 72 69 62 69 6e | 67 20 6d 61 74 63 68 69 |escribin|g matchi|
|000016a0| 6e 67 20 73 75 62 73 65 | 71 75 65 6e 63 65 73 2e |ng subse|quences.|
|000016b0| 0a 0a 20 20 20 20 67 65 | 74 5f 6f 70 63 6f 64 65 |.. ge|t_opcode|
|000016c0| 73 28 29 0a 20 20 20 20 | 20 20 20 20 52 65 74 75 |s(). | Retu|
|000016d0| 72 6e 20 6c 69 73 74 20 | 6f 66 20 35 2d 74 75 70 |rn list |of 5-tup|
|000016e0| 6c 65 73 20 64 65 73 63 | 72 69 62 69 6e 67 20 68 |les desc|ribing h|
|000016f0| 6f 77 20 74 6f 20 74 75 | 72 6e 20 61 20 69 6e 74 |ow to tu|rn a int|
|00001700| 6f 20 62 2e 0a 0a 20 20 | 20 20 72 61 74 69 6f 28 |o b... | ratio(|
|00001710| 29 0a 20 20 20 20 20 20 | 20 20 52 65 74 75 72 6e |). | Return|
|00001720| 20 61 20 6d 65 61 73 75 | 72 65 20 6f 66 20 74 68 | a measu|re of th|
|00001730| 65 20 73 65 71 75 65 6e | 63 65 73 27 20 73 69 6d |e sequen|ces' sim|
|00001740| 69 6c 61 72 69 74 79 20 | 28 66 6c 6f 61 74 20 69 |ilarity |(float i|
|00001750| 6e 20 5b 30 2c 31 5d 29 | 2e 0a 0a 20 20 20 20 71 |n [0,1])|... q|
|00001760| 75 69 63 6b 5f 72 61 74 | 69 6f 28 29 0a 20 20 20 |uick_rat|io(). |
|00001770| 20 20 20 20 20 52 65 74 | 75 72 6e 20 61 6e 20 75 | Ret|urn an u|
|00001780| 70 70 65 72 20 62 6f 75 | 6e 64 20 6f 6e 20 2e 72 |pper bou|nd on .r|
|00001790| 61 74 69 6f 28 29 20 72 | 65 6c 61 74 69 76 65 6c |atio() r|elativel|
|000017a0| 79 20 71 75 69 63 6b 6c | 79 2e 0a 0a 20 20 20 20 |y quickl|y... |
|000017b0| 72 65 61 6c 5f 71 75 69 | 63 6b 5f 72 61 74 69 6f |real_qui|ck_ratio|
|000017c0| 28 29 0a 20 20 20 20 20 | 20 20 20 52 65 74 75 72 |(). | Retur|
|000017d0| 6e 20 61 6e 20 75 70 70 | 65 72 20 62 6f 75 6e 64 |n an upp|er bound|
|000017e0| 20 6f 6e 20 72 61 74 69 | 6f 28 29 20 76 65 72 79 | on rati|o() very|
|000017f0| 20 71 75 69 63 6b 6c 79 | 2e 0a 20 20 20 20 74 00 | quickly|.. t.|
|00001800| 00 00 00 63 04 00 00 00 | 04 00 00 00 03 00 00 00 |...c....|........|
|00001810| 43 00 00 00 73 2d 00 00 | 00 7c 01 00 7c 00 00 5f |C...s-..|.|..|.._|
|00001820| 00 00 64 01 00 04 7c 00 | 00 5f 02 00 7c 00 00 5f |..d...|.|._..|.._|
|00001830| 03 00 7c 00 00 69 04 00 | 7c 02 00 7c 03 00 83 02 |..|..i..||..|....|
|00001840| 00 01 64 01 00 53 28 02 | 00 00 00 73 5b 03 00 00 |..d..S(.|...s[...|
|00001850| 43 6f 6e 73 74 72 75 63 | 74 20 61 20 53 65 71 75 |Construc|t a Sequ|
|00001860| 65 6e 63 65 4d 61 74 63 | 68 65 72 2e 0a 0a 20 20 |enceMatc|her... |
|00001870| 20 20 20 20 20 20 4f 70 | 74 69 6f 6e 61 6c 20 61 | Op|tional a|
|00001880| 72 67 20 69 73 6a 75 6e | 6b 20 69 73 20 4e 6f 6e |rg isjun|k is Non|
|00001890| 65 20 28 74 68 65 20 64 | 65 66 61 75 6c 74 29 2c |e (the d|efault),|
|000018a0| 20 6f 72 20 61 20 6f 6e | 65 2d 61 72 67 75 6d 65 | or a on|e-argume|
|000018b0| 6e 74 0a 20 20 20 20 20 | 20 20 20 66 75 6e 63 74 |nt. | funct|
|000018c0| 69 6f 6e 20 74 68 61 74 | 20 74 61 6b 65 73 20 61 |ion that| takes a|
|000018d0| 20 73 65 71 75 65 6e 63 | 65 20 65 6c 65 6d 65 6e | sequenc|e elemen|
|000018e0| 74 20 61 6e 64 20 72 65 | 74 75 72 6e 73 20 74 72 |t and re|turns tr|
|000018f0| 75 65 20 69 66 66 20 74 | 68 65 0a 20 20 20 20 20 |ue iff t|he. |
|00001900| 20 20 20 65 6c 65 6d 65 | 6e 74 20 69 73 20 6a 75 | eleme|nt is ju|
|00001910| 6e 6b 2e 20 20 4e 6f 6e | 65 20 69 73 20 65 71 75 |nk. Non|e is equ|
|00001920| 69 76 61 6c 65 6e 74 20 | 74 6f 20 70 61 73 73 69 |ivalent |to passi|
|00001930| 6e 67 20 22 6c 61 6d 62 | 64 61 20 78 3a 20 30 22 |ng "lamb|da x: 0"|
|00001940| 2c 20 69 2e 65 2e 0a 20 | 20 20 20 20 20 20 20 6e |, i.e.. | n|
|00001950| 6f 20 65 6c 65 6d 65 6e | 74 73 20 61 72 65 20 63 |o elemen|ts are c|
|00001960| 6f 6e 73 69 64 65 72 65 | 64 20 74 6f 20 62 65 20 |onsidere|d to be |
|00001970| 6a 75 6e 6b 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |junk. F|or examp|
|00001980| 6c 65 2c 20 70 61 73 73 | 0a 20 20 20 20 20 20 20 |le, pass|. |
|00001990| 20 20 20 20 20 6c 61 6d | 62 64 61 20 78 3a 20 78 | lam|bda x: x|
|000019a0| 20 69 6e 20 22 20 5c 74 | 22 0a 20 20 20 20 20 20 | in " \t|". |
|000019b0| 20 20 69 66 20 79 6f 75 | 27 72 65 20 63 6f 6d 70 | if you|'re comp|
|000019c0| 61 72 69 6e 67 20 6c 69 | 6e 65 73 20 61 73 20 73 |aring li|nes as s|
|000019d0| 65 71 75 65 6e 63 65 73 | 20 6f 66 20 63 68 61 72 |equences| of char|
|000019e0| 61 63 74 65 72 73 2c 20 | 61 6e 64 20 64 6f 6e 27 |acters, |and don'|
|000019f0| 74 0a 20 20 20 20 20 20 | 20 20 77 61 6e 74 20 74 |t. | want t|
|00001a00| 6f 20 73 79 6e 63 68 20 | 75 70 20 6f 6e 20 62 6c |o synch |up on bl|
|00001a10| 61 6e 6b 73 20 6f 72 20 | 68 61 72 64 20 74 61 62 |anks or |hard tab|
|00001a20| 73 2e 0a 0a 20 20 20 20 | 20 20 20 20 4f 70 74 69 |s... | Opti|
|00001a30| 6f 6e 61 6c 20 61 72 67 | 20 61 20 69 73 20 74 68 |onal arg| a is th|
|00001a40| 65 20 66 69 72 73 74 20 | 6f 66 20 74 77 6f 20 73 |e first |of two s|
|00001a50| 65 71 75 65 6e 63 65 73 | 20 74 6f 20 62 65 20 63 |equences| to be c|
|00001a60| 6f 6d 70 61 72 65 64 2e | 20 20 42 79 0a 20 20 20 |ompared.| By. |
|00001a70| 20 20 20 20 20 64 65 66 | 61 75 6c 74 2c 20 61 6e | def|ault, an|
|00001a80| 20 65 6d 70 74 79 20 73 | 74 72 69 6e 67 2e 20 20 | empty s|tring. |
|00001a90| 54 68 65 20 65 6c 65 6d | 65 6e 74 73 20 6f 66 20 |The elem|ents of |
|00001aa0| 61 20 6d 75 73 74 20 62 | 65 20 68 61 73 68 61 62 |a must b|e hashab|
|00001ab0| 6c 65 2e 20 20 53 65 65 | 0a 20 20 20 20 20 20 20 |le. See|. |
|00001ac0| 20 61 6c 73 6f 20 2e 73 | 65 74 5f 73 65 71 73 28 | also .s|et_seqs(|
|00001ad0| 29 20 61 6e 64 20 2e 73 | 65 74 5f 73 65 71 31 28 |) and .s|et_seq1(|
|00001ae0| 29 2e 0a 0a 20 20 20 20 | 20 20 20 20 4f 70 74 69 |)... | Opti|
|00001af0| 6f 6e 61 6c 20 61 72 67 | 20 62 20 69 73 20 74 68 |onal arg| b is th|
|00001b00| 65 20 73 65 63 6f 6e 64 | 20 6f 66 20 74 77 6f 20 |e second| of two |
|00001b10| 73 65 71 75 65 6e 63 65 | 73 20 74 6f 20 62 65 20 |sequence|s to be |
|00001b20| 63 6f 6d 70 61 72 65 64 | 2e 20 20 42 79 0a 20 20 |compared|. By. |
|00001b30| 20 20 20 20 20 20 64 65 | 66 61 75 6c 74 2c 20 61 | de|fault, a|
|00001b40| 6e 20 65 6d 70 74 79 20 | 73 74 72 69 6e 67 2e 20 |n empty |string. |
|00001b50| 20 54 68 65 20 65 6c 65 | 6d 65 6e 74 73 20 6f 66 | The ele|ments of|
|00001b60| 20 62 20 6d 75 73 74 20 | 62 65 20 68 61 73 68 61 | b must |be hasha|
|00001b70| 62 6c 65 2e 20 53 65 65 | 0a 20 20 20 20 20 20 20 |ble. See|. |
|00001b80| 20 61 6c 73 6f 20 2e 73 | 65 74 5f 73 65 71 73 28 | also .s|et_seqs(|
|00001b90| 29 20 61 6e 64 20 2e 73 | 65 74 5f 73 65 71 32 28 |) and .s|et_seq2(|
|00001ba0| 29 2e 0a 20 20 20 20 20 | 20 20 20 4e 28 05 00 00 |).. | N(...|
|00001bb0| 00 74 06 00 00 00 69 73 | 6a 75 6e 6b 74 04 00 00 |.t....is|junkt...|
|00001bc0| 00 4e 6f 6e 65 74 01 00 | 00 00 61 74 01 00 00 00 |.Nonet..|..at....|
|00001bd0| 62 74 08 00 00 00 73 65 | 74 5f 73 65 71 73 28 04 |bt....se|t_seqs(.|
|00001be0| 00 00 00 74 04 00 00 00 | 73 65 6c 66 52 11 00 00 |...t....|selfR...|
|00001bf0| 00 52 13 00 00 00 52 14 | 00 00 00 28 00 00 00 00 |.R....R.|...(....|
|00001c00| 28 00 00 00 00 73 1d 00 | 00 00 2f 75 73 72 2f 6c |(....s..|../usr/l|
|00001c10| 69 62 2f 70 79 74 68 6f | 6e 32 2e 36 2f 64 69 66 |ib/pytho|n2.6/dif|
|00001c20| 66 6c 69 62 2e 70 79 74 | 08 00 00 00 5f 5f 69 6e |flib.pyt|....__in|
|00001c30| 69 74 5f 5f 9a 00 00 00 | 73 06 00 00 00 00 3b 09 |it__....|s.....;.|
|00001c40| 01 10 01 63 03 00 00 00 | 03 00 00 00 02 00 00 00 |...c....|........|
|00001c50| 43 00 00 00 73 1e 00 00 | 00 7c 00 00 69 00 00 7c |C...s...|.|..i..||
|00001c60| 01 00 83 01 00 01 7c 00 | 00 69 01 00 7c 02 00 83 |......|.|.i..|...|
|00001c70| 01 00 01 64 01 00 53 28 | 02 00 00 00 73 9b 00 00 |...d..S(|....s...|
|00001c80| 00 53 65 74 20 74 68 65 | 20 74 77 6f 20 73 65 71 |.Set the| two seq|
|00001c90| 75 65 6e 63 65 73 20 74 | 6f 20 62 65 20 63 6f 6d |uences t|o be com|
|00001ca0| 70 61 72 65 64 2e 0a 0a | 20 20 20 20 20 20 20 20 |pared...| |
|00001cb0| 3e 3e 3e 20 73 20 3d 20 | 53 65 71 75 65 6e 63 65 |>>> s = |Sequence|
|00001cc0| 4d 61 74 63 68 65 72 28 | 29 0a 20 20 20 20 20 20 |Matcher(|). |
|00001cd0| 20 20 3e 3e 3e 20 73 2e | 73 65 74 5f 73 65 71 73 | >>> s.|set_seqs|
|00001ce0| 28 22 61 62 63 64 22 2c | 20 22 62 63 64 65 22 29 |("abcd",| "bcde")|
|00001cf0| 0a 20 20 20 20 20 20 20 | 20 3e 3e 3e 20 73 2e 72 |. | >>> s.r|
|00001d00| 61 74 69 6f 28 29 0a 20 | 20 20 20 20 20 20 20 30 |atio(). | 0|
|00001d10| 2e 37 35 0a 20 20 20 20 | 20 20 20 20 4e 28 02 00 |.75. | N(..|
|00001d20| 00 00 74 08 00 00 00 73 | 65 74 5f 73 65 71 31 74 |..t....s|et_seq1t|
|00001d30| 08 00 00 00 73 65 74 5f | 73 65 71 32 28 03 00 00 |....set_|seq2(...|
|00001d40| 00 52 16 00 00 00 52 13 | 00 00 00 52 14 00 00 00 |.R....R.|...R....|
|00001d50| 28 00 00 00 00 28 00 00 | 00 00 73 1d 00 00 00 2f |(....(..|..s..../|
|00001d60| 75 73 72 2f 6c 69 62 2f | 70 79 74 68 6f 6e 32 2e |usr/lib/|python2.|
|00001d70| 36 2f 64 69 66 66 6c 69 | 62 2e 70 79 52 15 00 00 |6/diffli|b.pyR...|
|00001d80| 00 d9 00 00 00 73 04 00 | 00 00 00 09 0d 01 63 02 |.....s..|......c.|
|00001d90| 00 00 00 02 00 00 00 03 | 00 00 00 43 00 00 00 73 |........|...C...s|
|00001da0| 32 00 00 00 7c 01 00 7c | 00 00 69 00 00 6a 08 00 |2...|..||..i..j..|
|00001db0| 6f 05 00 01 64 01 00 53 | 01 7c 01 00 7c 00 00 5f |o...d..S|.|..|.._|
|00001dc0| 00 00 64 01 00 04 7c 00 | 00 5f 02 00 7c 00 00 5f |..d...|.|._..|.._|
|00001dd0| 03 00 64 01 00 53 28 02 | 00 00 00 73 4d 02 00 00 |..d..S(.|...sM...|
|00001de0| 53 65 74 20 74 68 65 20 | 66 69 72 73 74 20 73 65 |Set the |first se|
|00001df0| 71 75 65 6e 63 65 20 74 | 6f 20 62 65 20 63 6f 6d |quence t|o be com|
|00001e00| 70 61 72 65 64 2e 0a 0a | 20 20 20 20 20 20 20 20 |pared...| |
|00001e10| 54 68 65 20 73 65 63 6f | 6e 64 20 73 65 71 75 65 |The seco|nd seque|
|00001e20| 6e 63 65 20 74 6f 20 62 | 65 20 63 6f 6d 70 61 72 |nce to b|e compar|
|00001e30| 65 64 20 69 73 20 6e 6f | 74 20 63 68 61 6e 67 65 |ed is no|t change|
|00001e40| 64 2e 0a 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |d... | >>> |
|00001e50| 73 20 3d 20 53 65 71 75 | 65 6e 63 65 4d 61 74 63 |s = Sequ|enceMatc|
|00001e60| 68 65 72 28 4e 6f 6e 65 | 2c 20 22 61 62 63 64 22 |her(None|, "abcd"|
|00001e70| 2c 20 22 62 63 64 65 22 | 29 0a 20 20 20 20 20 20 |, "bcde"|). |
|00001e80| 20 20 3e 3e 3e 20 73 2e | 72 61 74 69 6f 28 29 0a | >>> s.|ratio().|
|00001e90| 20 20 20 20 20 20 20 20 | 30 2e 37 35 0a 20 20 20 | |0.75. |
|00001ea0| 20 20 20 20 20 3e 3e 3e | 20 73 2e 73 65 74 5f 73 | >>>| s.set_s|
|00001eb0| 65 71 31 28 22 62 63 64 | 65 22 29 0a 20 20 20 20 |eq1("bcd|e"). |
|00001ec0| 20 20 20 20 3e 3e 3e 20 | 73 2e 72 61 74 69 6f 28 | >>> |s.ratio(|
|00001ed0| 29 0a 20 20 20 20 20 20 | 20 20 31 2e 30 0a 20 20 |). | 1.0. |
|00001ee0| 20 20 20 20 20 20 3e 3e | 3e 0a 0a 20 20 20 20 20 | >>|>.. |
|00001ef0| 20 20 20 53 65 71 75 65 | 6e 63 65 4d 61 74 63 68 | Seque|nceMatch|
|00001f00| 65 72 20 63 6f 6d 70 75 | 74 65 73 20 61 6e 64 20 |er compu|tes and |
|00001f10| 63 61 63 68 65 73 20 64 | 65 74 61 69 6c 65 64 20 |caches d|etailed |
|00001f20| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 61 62 6f 75 |informat|ion abou|
|00001f30| 74 20 74 68 65 0a 20 20 | 20 20 20 20 20 20 73 65 |t the. | se|
|00001f40| 63 6f 6e 64 20 73 65 71 | 75 65 6e 63 65 2c 20 73 |cond seq|uence, s|
|00001f50| 6f 20 69 66 20 79 6f 75 | 20 77 61 6e 74 20 74 6f |o if you| want to|
|00001f60| 20 63 6f 6d 70 61 72 65 | 20 6f 6e 65 20 73 65 71 | compare| one seq|
|00001f70| 75 65 6e 63 65 20 53 20 | 61 67 61 69 6e 73 74 0a |uence S |against.|
|00001f80| 20 20 20 20 20 20 20 20 | 6d 61 6e 79 20 73 65 71 | |many seq|
|00001f90| 75 65 6e 63 65 73 2c 20 | 75 73 65 20 2e 73 65 74 |uences, |use .set|
|00001fa0| 5f 73 65 71 32 28 53 29 | 20 6f 6e 63 65 20 61 6e |_seq2(S)| once an|
|00001fb0| 64 20 63 61 6c 6c 20 2e | 73 65 74 5f 73 65 71 31 |d call .|set_seq1|
|00001fc0| 28 78 29 0a 20 20 20 20 | 20 20 20 20 72 65 70 65 |(x). | repe|
|00001fd0| 61 74 65 64 6c 79 20 66 | 6f 72 20 65 61 63 68 20 |atedly f|or each |
|00001fe0| 6f 66 20 74 68 65 20 6f | 74 68 65 72 20 73 65 71 |of the o|ther seq|
|00001ff0| 75 65 6e 63 65 73 2e 0a | 0a 20 20 20 20 20 20 20 |uences..|. |
|00002000| 20 53 65 65 20 61 6c 73 | 6f 20 73 65 74 5f 73 65 | See als|o set_se|
|00002010| 71 73 28 29 20 61 6e 64 | 20 73 65 74 5f 73 65 71 |qs() and| set_seq|
|00002020| 32 28 29 2e 0a 20 20 20 | 20 20 20 20 20 4e 28 04 |2().. | N(.|
|00002030| 00 00 00 52 13 00 00 00 | 52 12 00 00 00 74 0f 00 |...R....|R....t..|
|00002040| 00 00 6d 61 74 63 68 69 | 6e 67 5f 62 6c 6f 63 6b |..matchi|ng_block|
|00002050| 73 74 07 00 00 00 6f 70 | 63 6f 64 65 73 28 02 00 |st....op|codes(..|
|00002060| 00 00 52 16 00 00 00 52 | 13 00 00 00 28 00 00 00 |..R....R|....(...|
|00002070| 00 28 00 00 00 00 73 1d | 00 00 00 2f 75 73 72 2f |.(....s.|.../usr/|
|00002080| 6c 69 62 2f 70 79 74 68 | 6f 6e 32 2e 36 2f 64 69 |lib/pyth|on2.6/di|
|00002090| 66 66 6c 69 62 2e 70 79 | 52 18 00 00 00 e5 00 00 |fflib.py|R.......|
|000020a0| 00 73 08 00 00 00 00 15 | 10 01 05 01 09 01 63 02 |.s......|......c.|
|000020b0| 00 00 00 02 00 00 00 03 | 00 00 00 43 00 00 00 73 |........|...C...s|
|000020c0| 45 00 00 00 7c 01 00 7c | 00 00 69 00 00 6a 08 00 |E...|..||..i..j..|
|000020d0| 6f 05 00 01 64 01 00 53 | 01 7c 01 00 7c 00 00 5f |o...d..S|.|..|.._|
|000020e0| 00 00 64 01 00 04 7c 00 | 00 5f 02 00 7c 00 00 5f |..d...|.|._..|.._|
|000020f0| 03 00 64 01 00 7c 00 00 | 5f 04 00 7c 00 00 69 05 |..d..|..|_..|..i.|
|00002100| 00 83 00 00 01 64 01 00 | 53 28 02 00 00 00 73 4d |.....d..|S(....sM|
|00002110| 02 00 00 53 65 74 20 74 | 68 65 20 73 65 63 6f 6e |...Set t|he secon|
|00002120| 64 20 73 65 71 75 65 6e | 63 65 20 74 6f 20 62 65 |d sequen|ce to be|
|00002130| 20 63 6f 6d 70 61 72 65 | 64 2e 0a 0a 20 20 20 20 | compare|d... |
|00002140| 20 20 20 20 54 68 65 20 | 66 69 72 73 74 20 73 65 | The |first se|
|00002150| 71 75 65 6e 63 65 20 74 | 6f 20 62 65 20 63 6f 6d |quence t|o be com|
|00002160| 70 61 72 65 64 20 69 73 | 20 6e 6f 74 20 63 68 61 |pared is| not cha|
|00002170| 6e 67 65 64 2e 0a 0a 20 | 20 20 20 20 20 20 20 3e |nged... | >|
|00002180| 3e 3e 20 73 20 3d 20 53 | 65 71 75 65 6e 63 65 4d |>> s = S|equenceM|
|00002190| 61 74 63 68 65 72 28 4e | 6f 6e 65 2c 20 22 61 62 |atcher(N|one, "ab|
|000021a0| 63 64 22 2c 20 22 62 63 | 64 65 22 29 0a 20 20 20 |cd", "bc|de"). |
|000021b0| 20 20 20 20 20 3e 3e 3e | 20 73 2e 72 61 74 69 6f | >>>| s.ratio|
|000021c0| 28 29 0a 20 20 20 20 20 | 20 20 20 30 2e 37 35 0a |(). | 0.75.|
|000021d0| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 73 2e 73 65 | |>>> s.se|
|000021e0| 74 5f 73 65 71 32 28 22 | 61 62 63 64 22 29 0a 20 |t_seq2("|abcd"). |
|000021f0| 20 20 20 20 20 20 20 3e | 3e 3e 20 73 2e 72 61 74 | >|>> s.rat|
|00002200| 69 6f 28 29 0a 20 20 20 | 20 20 20 20 20 31 2e 30 |io(). | 1.0|
|00002210| 0a 20 20 20 20 20 20 20 | 20 3e 3e 3e 0a 0a 20 20 |. | >>>.. |
|00002220| 20 20 20 20 20 20 53 65 | 71 75 65 6e 63 65 4d 61 | Se|quenceMa|
|00002230| 74 63 68 65 72 20 63 6f | 6d 70 75 74 65 73 20 61 |tcher co|mputes a|
|00002240| 6e 64 20 63 61 63 68 65 | 73 20 64 65 74 61 69 6c |nd cache|s detail|
|00002250| 65 64 20 69 6e 66 6f 72 | 6d 61 74 69 6f 6e 20 61 |ed infor|mation a|
|00002260| 62 6f 75 74 20 74 68 65 | 0a 20 20 20 20 20 20 20 |bout the|. |
|00002270| 20 73 65 63 6f 6e 64 20 | 73 65 71 75 65 6e 63 65 | second |sequence|
|00002280| 2c 20 73 6f 20 69 66 20 | 79 6f 75 20 77 61 6e 74 |, so if |you want|
|00002290| 20 74 6f 20 63 6f 6d 70 | 61 72 65 20 6f 6e 65 20 | to comp|are one |
|000022a0| 73 65 71 75 65 6e 63 65 | 20 53 20 61 67 61 69 6e |sequence| S again|
|000022b0| 73 74 0a 20 20 20 20 20 | 20 20 20 6d 61 6e 79 20 |st. | many |
|000022c0| 73 65 71 75 65 6e 63 65 | 73 2c 20 75 73 65 20 2e |sequence|s, use .|
|000022d0| 73 65 74 5f 73 65 71 32 | 28 53 29 20 6f 6e 63 65 |set_seq2|(S) once|
|000022e0| 20 61 6e 64 20 63 61 6c | 6c 20 2e 73 65 74 5f 73 | and cal|l .set_s|
|000022f0| 65 71 31 28 78 29 0a 20 | 20 20 20 20 20 20 20 72 |eq1(x). | r|
|00002300| 65 70 65 61 74 65 64 6c | 79 20 66 6f 72 20 65 61 |epeatedl|y for ea|
|00002310| 63 68 20 6f 66 20 74 68 | 65 20 6f 74 68 65 72 20 |ch of th|e other |
|00002320| 73 65 71 75 65 6e 63 65 | 73 2e 0a 0a 20 20 20 20 |sequence|s... |
|00002330| 20 20 20 20 53 65 65 20 | 61 6c 73 6f 20 73 65 74 | See |also set|
|00002340| 5f 73 65 71 73 28 29 20 | 61 6e 64 20 73 65 74 5f |_seqs() |and set_|
|00002350| 73 65 71 31 28 29 2e 0a | 20 20 20 20 20 20 20 20 |seq1()..| |
|00002360| 4e 28 06 00 00 00 52 14 | 00 00 00 52 12 00 00 00 |N(....R.|...R....|
|00002370| 52 1a 00 00 00 52 1b 00 | 00 00 74 0a 00 00 00 66 |R....R..|..t....f|
|00002380| 75 6c 6c 62 63 6f 75 6e | 74 74 19 00 00 00 5f 53 |ullbcoun|tt...._S|
|00002390| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 5f 5f |equenceM|atcher__|
|000023a0| 63 68 61 69 6e 5f 62 28 | 02 00 00 00 52 16 00 00 |chain_b(|....R...|
|000023b0| 00 52 14 00 00 00 28 00 | 00 00 00 28 00 00 00 00 |.R....(.|...(....|
|000023c0| 73 1d 00 00 00 2f 75 73 | 72 2f 6c 69 62 2f 70 79 |s..../us|r/lib/py|
|000023d0| 74 68 6f 6e 32 2e 36 2f | 64 69 66 66 6c 69 62 2e |thon2.6/|difflib.|
|000023e0| 70 79 52 19 00 00 00 ff | 00 00 00 73 0c 00 00 00 |pyR.....|...s....|
|000023f0| 00 15 10 01 05 01 09 01 | 10 01 09 01 63 01 00 00 |........|....c...|
|00002400| 00 0b 00 00 00 09 00 00 | 00 43 00 00 00 73 4e 01 |........|.C...sN.|
|00002410| 00 00 7c 00 00 69 00 00 | 7d 01 00 74 01 00 7c 01 |..|..i..|}..t..|.|
|00002420| 00 83 01 00 7d 02 00 68 | 00 00 04 7c 00 00 5f 02 |....}..h|...|.._.|
|00002430| 00 7d 03 00 68 00 00 7d | 04 00 78 85 00 74 03 00 |.}..h..}|..x..t..|
|00002440| 7c 01 00 83 01 00 44 5d | 77 00 5c 02 00 7d 05 00 ||.....D]|w.\..}..|
|00002450| 7d 06 00 7c 06 00 7c 03 | 00 6a 06 00 6f 51 00 01 |}..|..|.|.j..oQ..|
|00002460| 7c 03 00 7c 06 00 19 7d | 07 00 7c 02 00 64 01 00 ||..|...}|..|..d..|
|00002470| 6a 05 00 6f 29 00 01 74 | 01 00 7c 07 00 83 01 00 |j..o)..t|..|.....|
|00002480| 64 02 00 14 7c 02 00 6a | 04 00 6f 12 00 01 64 03 |d...|..j|..o...d.|
|00002490| 00 7c 04 00 7c 06 00 3c | 7c 07 00 32 71 ac 00 01 |.|..|..<||..2q...|
|000024a0| 7c 07 00 69 04 00 7c 05 | 00 83 01 00 01 71 35 00 ||..i..|.|.....q5.|
|000024b0| 01 7c 05 00 67 01 00 7c | 03 00 7c 06 00 3c 71 35 |.|..g..||..|..<q5|
|000024c0| 00 57 78 15 00 7c 04 00 | 44 5d 0d 00 7d 06 00 7c |.Wx..|..|D]..}..||
|000024d0| 03 00 7c 06 00 3d 71 b7 | 00 57 7c 00 00 69 05 00 |..|..=q.|.W|..i..|
|000024e0| 7d 08 00 68 00 00 7d 09 | 00 7c 08 00 6f 54 00 01 |}..h..}.|.|..oT..|
|000024f0| 78 51 00 7c 04 00 7c 03 | 00 66 02 00 44 5d 3f 00 |xQ.|..|.|.f..D]?.|
|00002500| 7d 0a 00 78 36 00 7c 0a | 00 69 06 00 83 00 00 44 |}..x6.|.|.i.....D|
|00002510| 5d 28 00 7d 06 00 7c 08 | 00 7c 06 00 83 01 00 6f |](.}..|.|.|.....o|
|00002520| 15 00 01 64 03 00 7c 09 | 00 7c 06 00 3c 7c 0a 00 |...d..|.|.|..<|..|
|00002530| 7c 06 00 3d 71 fe 00 01 | 71 fe 00 57 71 eb 00 57 ||..=q...|q..Wq..W|
|00002540| 6e 01 00 01 7c 09 00 69 | 07 00 7c 00 00 5f 08 00 |n...|..i|..|.._..|
|00002550| 7c 04 00 69 07 00 7c 00 | 00 5f 09 00 64 00 00 53 ||..i..|.|._..d..S|
|00002560| 28 04 00 00 00 4e 69 c8 | 00 00 00 69 64 00 00 00 |(....Ni.|...id...|
|00002570| 69 01 00 00 00 28 0a 00 | 00 00 52 14 00 00 00 74 |i....(..|..R....t|
|00002580| 03 00 00 00 6c 65 6e 74 | 03 00 00 00 62 32 6a 74 |....lent|....b2jt|
|00002590| 09 00 00 00 65 6e 75 6d | 65 72 61 74 65 74 06 00 |....enum|eratet..|
|000025a0| 00 00 61 70 70 65 6e 64 | 52 11 00 00 00 74 04 00 |..append|R....t..|
|000025b0| 00 00 6b 65 79 73 74 0c | 00 00 00 5f 5f 63 6f 6e |..keyst.|...__con|
|000025c0| 74 61 69 6e 73 5f 5f 74 | 07 00 00 00 69 73 62 6a |tains__t|....isbj|
|000025d0| 75 6e 6b 74 0a 00 00 00 | 69 73 62 70 6f 70 75 6c |unkt....|isbpopul|
|000025e0| 61 72 28 0b 00 00 00 52 | 16 00 00 00 52 14 00 00 |ar(....R|....R...|
|000025f0| 00 74 01 00 00 00 6e 52 | 1f 00 00 00 74 0b 00 00 |.t....nR|....t...|
|00002600| 00 70 6f 70 75 6c 61 72 | 64 69 63 74 74 01 00 00 |.popular|dictt...|
|00002610| 00 69 74 03 00 00 00 65 | 6c 74 74 07 00 00 00 69 |.it....e|ltt....i|
|00002620| 6e 64 69 63 65 73 52 11 | 00 00 00 74 08 00 00 00 |ndicesR.|...t....|
|00002630| 6a 75 6e 6b 64 69 63 74 | 74 01 00 00 00 64 28 00 |junkdict|t....d(.|
|00002640| 00 00 00 28 00 00 00 00 | 73 1d 00 00 00 2f 75 73 |...(....|s..../us|
|00002650| 72 2f 6c 69 62 2f 70 79 | 74 68 6f 6e 32 2e 36 2f |r/lib/py|thon2.6/|
|00002660| 64 69 66 66 6c 69 62 2e | 70 79 74 09 00 00 00 5f |difflib.|pyt...._|
|00002670| 5f 63 68 61 69 6e 5f 62 | 2c 01 00 00 73 38 00 00 |_chain_b|,...s8..|
|00002680| 00 00 0b 09 01 0c 01 0d | 01 06 01 0d 00 0c 01 0d |........|........|
|00002690| 01 0a 01 24 01 0a 01 08 | 02 11 02 11 03 07 00 06 |...$....|........|
|000026a0| 01 0b 06 09 01 06 01 07 | 01 0d 00 06 01 0d 00 06 |........|........|
|000026b0| 01 0d 01 0a 01 17 07 0c | 01 63 05 00 00 00 13 00 |........|.c......|
|000026c0| 00 00 06 00 00 00 43 00 | 00 00 73 da 02 00 00 7c |......C.|..s....||
|000026d0| 00 00 69 00 00 7c 00 00 | 69 01 00 7c 00 00 69 02 |..i..|..|i..|..i.|
|000026e0| 00 7c 00 00 69 03 00 66 | 04 00 5c 04 00 7d 05 00 |.|..i..f|..\..}..|
|000026f0| 7d 06 00 7d 07 00 7d 08 | 00 7c 01 00 7c 03 00 64 |}..}..}.|.|..|..d|
|00002700| 01 00 03 02 7d 09 00 7d | 0a 00 7d 0b 00 68 00 00 |....}..}|..}..h..|
|00002710| 7d 0c 00 67 00 00 7d 0d | 00 78 c7 00 74 04 00 7c |}..g..}.|.x..t..||
|00002720| 01 00 7c 02 00 83 02 00 | 44 5d b6 00 7d 0e 00 7c |..|.....|D]..}..||
|00002730| 0c 00 69 05 00 7d 0f 00 | 68 00 00 7d 10 00 78 98 |..i..}..|h..}..x.|
|00002740| 00 7c 07 00 69 05 00 7c | 05 00 7c 0e 00 19 7c 0d |.|..i..||..|...|.|
|00002750| 00 83 02 00 44 5d 80 00 | 7d 11 00 7c 11 00 7c 03 |....D]..|}..|..|.|
|00002760| 00 6a 00 00 6f 07 00 01 | 71 86 00 6e 01 00 01 7c |.j..o...|q..n...||
|00002770| 11 00 7c 04 00 6a 05 00 | 6f 05 00 01 50 6e 01 00 |..|..j..|o...Pn..|
|00002780| 01 7c 0f 00 7c 11 00 64 | 02 00 18 64 01 00 83 02 |.|..|..d|...d....|
|00002790| 00 64 02 00 17 04 7d 12 | 00 7c 10 00 7c 11 00 3c |.d....}.|.|..|..<|
|000027a0| 7c 12 00 7c 0b 00 6a 04 | 00 6f 28 00 01 7c 0e 00 ||..|..j.|.o(..|..|
|000027b0| 7c 12 00 18 64 02 00 17 | 7c 11 00 7c 12 00 18 64 ||...d...||..|...d|
|000027c0| 02 00 17 7c 12 00 03 02 | 7d 09 00 7d 0a 00 7d 0b |...|....|}..}..}.|
|000027d0| 00 71 86 00 01 71 86 00 | 57 7c 10 00 7d 0c 00 71 |.q...q..|W|..}..q|
|000027e0| 5a 00 57 78 72 00 7c 09 | 00 7c 01 00 6a 04 00 6f |Z.Wxr.|.|.|..j..o|
|000027f0| 64 00 01 7c 0a 00 7c 03 | 00 6a 04 00 6f 57 00 01 |d..|..|.|.j..oW..|
|00002800| 7c 08 00 7c 06 00 7c 0a | 00 64 02 00 18 19 83 01 ||..|..|.|.d......|
|00002810| 00 0c 6f 41 00 01 7c 05 | 00 7c 09 00 64 02 00 18 |..oA..|.|.|..d...|
|00002820| 19 7c 06 00 7c 0a 00 64 | 02 00 18 19 6a 02 00 6f |.|..|..d|....j..o|
|00002830| 24 00 01 7c 09 00 64 02 | 00 18 7c 0a 00 64 02 00 |$..|..d.|..|..d..|
|00002840| 18 7c 0b 00 64 02 00 17 | 03 02 7d 09 00 7d 0a 00 |.|..d...|..}..}..|
|00002850| 7d 0b 00 71 17 01 01 57 | 78 64 00 7c 09 00 7c 0b |}..q...W|xd.|..|.|
|00002860| 00 17 7c 02 00 6a 00 00 | 6f 52 00 01 7c 0a 00 7c |..|..j..|oR..|..||
|00002870| 0b 00 17 7c 04 00 6a 00 | 00 6f 41 00 01 7c 08 00 |...|..j.|.oA..|..|
|00002880| 7c 06 00 7c 0a 00 7c 0b | 00 17 19 83 01 00 0c 6f ||..|..|.|.......o|
|00002890| 2b 00 01 7c 05 00 7c 09 | 00 7c 0b 00 17 19 7c 06 |+..|..|.|.|....|.|
|000028a0| 00 7c 0a 00 7c 0b 00 17 | 19 6a 02 00 6f 0e 00 01 |.|..|...|.j..o...|
|000028b0| 7c 0b 00 64 02 00 37 7d | 0b 00 71 8c 01 01 57 78 ||..d..7}|..q...Wx|
|000028c0| 71 00 7c 09 00 7c 01 00 | 6a 04 00 6f 63 00 01 7c |q.|..|..|j..oc..||
|000028d0| 0a 00 7c 03 00 6a 04 00 | 6f 56 00 01 7c 08 00 7c |..|..j..|oV..|..||
|000028e0| 06 00 7c 0a 00 64 02 00 | 18 19 83 01 00 6f 41 00 |..|..d..|.....oA.|
|000028f0| 01 7c 05 00 7c 09 00 64 | 02 00 18 19 7c 06 00 7c |.|..|..d|....|..||
|00002900| 0a 00 64 02 00 18 19 6a | 02 00 6f 24 00 01 7c 09 |..d....j|..o$..|.|
|00002910| 00 64 02 00 18 7c 0a 00 | 64 02 00 18 7c 0b 00 64 |.d...|..|d...|..d|
|00002920| 02 00 17 03 02 7d 09 00 | 7d 0a 00 7d 0b 00 71 f3 |.....}..|}..}..q.|
|00002930| 01 01 57 78 63 00 7c 09 | 00 7c 0b 00 17 7c 02 00 |..Wxc.|.|.|...|..|
|00002940| 6a 00 00 6f 51 00 01 7c | 0a 00 7c 0b 00 17 7c 04 |j..oQ..||..|...|.|
|00002950| 00 6a 00 00 6f 40 00 01 | 7c 08 00 7c 06 00 7c 0a |.j..o@..||..|..|.|
|00002960| 00 7c 0b 00 17 19 83 01 | 00 6f 2b 00 01 7c 05 00 |.|......|.o+..|..|
|00002970| 7c 09 00 7c 0b 00 17 19 | 7c 06 00 7c 0a 00 7c 0b ||..|....||..|..|.|
|00002980| 00 17 19 6a 02 00 6f 0e | 00 01 7c 0b 00 64 02 00 |...j..o.|..|..d..|
|00002990| 17 7d 0b 00 71 67 02 01 | 57 74 06 00 7c 09 00 7c |.}..qg..|Wt..|..||
|000029a0| 0a 00 7c 0b 00 83 03 00 | 53 28 03 00 00 00 73 f2 |..|.....|S(....s.|
|000029b0| 06 00 00 46 69 6e 64 20 | 6c 6f 6e 67 65 73 74 20 |...Find |longest |
|000029c0| 6d 61 74 63 68 69 6e 67 | 20 62 6c 6f 63 6b 20 69 |matching| block i|
|000029d0| 6e 20 61 5b 61 6c 6f 3a | 61 68 69 5d 20 61 6e 64 |n a[alo:|ahi] and|
|000029e0| 20 62 5b 62 6c 6f 3a 62 | 68 69 5d 2e 0a 0a 20 20 | b[blo:b|hi]... |
|000029f0| 20 20 20 20 20 20 49 66 | 20 69 73 6a 75 6e 6b 20 | If| isjunk |
|00002a00| 69 73 20 6e 6f 74 20 64 | 65 66 69 6e 65 64 3a 0a |is not d|efined:.|
|00002a10| 0a 20 20 20 20 20 20 20 | 20 52 65 74 75 72 6e 20 |. | Return |
|00002a20| 28 69 2c 6a 2c 6b 29 20 | 73 75 63 68 20 74 68 61 |(i,j,k) |such tha|
|00002a30| 74 20 61 5b 69 3a 69 2b | 6b 5d 20 69 73 20 65 71 |t a[i:i+|k] is eq|
|00002a40| 75 61 6c 20 74 6f 20 62 | 5b 6a 3a 6a 2b 6b 5d 2c |ual to b|[j:j+k],|
|00002a50| 20 77 68 65 72 65 0a 20 | 20 20 20 20 20 20 20 20 | where. | |
|00002a60| 20 20 20 61 6c 6f 20 3c | 3d 20 69 20 3c 3d 20 69 | alo <|= i <= i|
|00002a70| 2b 6b 20 3c 3d 20 61 68 | 69 0a 20 20 20 20 20 20 |+k <= ah|i. |
|00002a80| 20 20 20 20 20 20 62 6c | 6f 20 3c 3d 20 6a 20 3c | bl|o <= j <|
|00002a90| 3d 20 6a 2b 6b 20 3c 3d | 20 62 68 69 0a 20 20 20 |= j+k <=| bhi. |
|00002aa0| 20 20 20 20 20 61 6e 64 | 20 66 6f 72 20 61 6c 6c | and| for all|
|00002ab0| 20 28 69 27 2c 6a 27 2c | 6b 27 29 20 6d 65 65 74 | (i',j',|k') meet|
|00002ac0| 69 6e 67 20 74 68 6f 73 | 65 20 63 6f 6e 64 69 74 |ing thos|e condit|
|00002ad0| 69 6f 6e 73 2c 0a 20 20 | 20 20 20 20 20 20 20 20 |ions,. | |
|00002ae0| 20 20 6b 20 3e 3d 20 6b | 27 0a 20 20 20 20 20 20 | k >= k|'. |
|00002af0| 20 20 20 20 20 20 69 20 | 3c 3d 20 69 27 0a 20 20 | i |<= i'. |
|00002b00| 20 20 20 20 20 20 20 20 | 20 20 61 6e 64 20 69 66 | | and if|
|00002b10| 20 69 20 3d 3d 20 69 27 | 2c 20 6a 20 3c 3d 20 6a | i == i'|, j <= j|
|00002b20| 27 0a 0a 20 20 20 20 20 | 20 20 20 49 6e 20 6f 74 |'.. | In ot|
|00002b30| 68 65 72 20 77 6f 72 64 | 73 2c 20 6f 66 20 61 6c |her word|s, of al|
|00002b40| 6c 20 6d 61 78 69 6d 61 | 6c 20 6d 61 74 63 68 69 |l maxima|l matchi|
|00002b50| 6e 67 20 62 6c 6f 63 6b | 73 2c 20 72 65 74 75 72 |ng block|s, retur|
|00002b60| 6e 20 6f 6e 65 20 74 68 | 61 74 0a 20 20 20 20 20 |n one th|at. |
|00002b70| 20 20 20 73 74 61 72 74 | 73 20 65 61 72 6c 69 65 | start|s earlie|
|00002b80| 73 74 20 69 6e 20 61 2c | 20 61 6e 64 20 6f 66 20 |st in a,| and of |
|00002b90| 61 6c 6c 20 74 68 6f 73 | 65 20 6d 61 78 69 6d 61 |all thos|e maxima|
|00002ba0| 6c 20 6d 61 74 63 68 69 | 6e 67 20 62 6c 6f 63 6b |l matchi|ng block|
|00002bb0| 73 20 74 68 61 74 0a 20 | 20 20 20 20 20 20 20 73 |s that. | s|
|00002bc0| 74 61 72 74 20 65 61 72 | 6c 69 65 73 74 20 69 6e |tart ear|liest in|
|00002bd0| 20 61 2c 20 72 65 74 75 | 72 6e 20 74 68 65 20 6f | a, retu|rn the o|
|00002be0| 6e 65 20 74 68 61 74 20 | 73 74 61 72 74 73 20 65 |ne that |starts e|
|00002bf0| 61 72 6c 69 65 73 74 20 | 69 6e 20 62 2e 0a 0a 20 |arliest |in b... |
|00002c00| 20 20 20 20 20 20 20 3e | 3e 3e 20 73 20 3d 20 53 | >|>> s = S|
|00002c10| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 28 4e |equenceM|atcher(N|
|00002c20| 6f 6e 65 2c 20 22 20 61 | 62 63 64 22 2c 20 22 61 |one, " a|bcd", "a|
|00002c30| 62 63 64 20 61 62 63 64 | 22 29 0a 20 20 20 20 20 |bcd abcd|"). |
|00002c40| 20 20 20 3e 3e 3e 20 73 | 2e 66 69 6e 64 5f 6c 6f | >>> s|.find_lo|
|00002c50| 6e 67 65 73 74 5f 6d 61 | 74 63 68 28 30 2c 20 35 |ngest_ma|tch(0, 5|
|00002c60| 2c 20 30 2c 20 39 29 0a | 20 20 20 20 20 20 20 20 |, 0, 9).| |
|00002c70| 4d 61 74 63 68 28 61 3d | 30 2c 20 62 3d 34 2c 20 |Match(a=|0, b=4, |
|00002c80| 73 69 7a 65 3d 35 29 0a | 0a 20 20 20 20 20 20 20 |size=5).|. |
|00002c90| 20 49 66 20 69 73 6a 75 | 6e 6b 20 69 73 20 64 65 | If isju|nk is de|
|00002ca0| 66 69 6e 65 64 2c 20 66 | 69 72 73 74 20 74 68 65 |fined, f|irst the|
|00002cb0| 20 6c 6f 6e 67 65 73 74 | 20 6d 61 74 63 68 69 6e | longest| matchin|
|00002cc0| 67 20 62 6c 6f 63 6b 20 | 69 73 0a 20 20 20 20 20 |g block |is. |
|00002cd0| 20 20 20 64 65 74 65 72 | 6d 69 6e 65 64 20 61 73 | deter|mined as|
|00002ce0| 20 61 62 6f 76 65 2c 20 | 62 75 74 20 77 69 74 68 | above, |but with|
|00002cf0| 20 74 68 65 20 61 64 64 | 69 74 69 6f 6e 61 6c 20 | the add|itional |
|00002d00| 72 65 73 74 72 69 63 74 | 69 6f 6e 20 74 68 61 74 |restrict|ion that|
|00002d10| 20 6e 6f 0a 20 20 20 20 | 20 20 20 20 6a 75 6e 6b | no. | junk|
|00002d20| 20 65 6c 65 6d 65 6e 74 | 20 61 70 70 65 61 72 73 | element| appears|
|00002d30| 20 69 6e 20 74 68 65 20 | 62 6c 6f 63 6b 2e 20 20 | in the |block. |
|00002d40| 54 68 65 6e 20 74 68 61 | 74 20 62 6c 6f 63 6b 20 |Then tha|t block |
|00002d50| 69 73 20 65 78 74 65 6e | 64 65 64 20 61 73 0a 20 |is exten|ded as. |
|00002d60| 20 20 20 20 20 20 20 66 | 61 72 20 61 73 20 70 6f | f|ar as po|
|00002d70| 73 73 69 62 6c 65 20 62 | 79 20 6d 61 74 63 68 69 |ssible b|y matchi|
|00002d80| 6e 67 20 28 6f 6e 6c 79 | 29 20 6a 75 6e 6b 20 65 |ng (only|) junk e|
|00002d90| 6c 65 6d 65 6e 74 73 20 | 6f 6e 20 62 6f 74 68 20 |lements |on both |
|00002da0| 73 69 64 65 73 2e 20 20 | 53 6f 0a 20 20 20 20 20 |sides. |So. |
|00002db0| 20 20 20 74 68 65 20 72 | 65 73 75 6c 74 69 6e 67 | the r|esulting|
|00002dc0| 20 62 6c 6f 63 6b 20 6e | 65 76 65 72 20 6d 61 74 | block n|ever mat|
|00002dd0| 63 68 65 73 20 6f 6e 20 | 6a 75 6e 6b 20 65 78 63 |ches on |junk exc|
|00002de0| 65 70 74 20 61 73 20 69 | 64 65 6e 74 69 63 61 6c |ept as i|dentical|
|00002df0| 20 6a 75 6e 6b 0a 20 20 | 20 20 20 20 20 20 68 61 | junk. | ha|
|00002e00| 70 70 65 6e 73 20 74 6f | 20 62 65 20 61 64 6a 61 |ppens to| be adja|
|00002e10| 63 65 6e 74 20 74 6f 20 | 61 6e 20 22 69 6e 74 65 |cent to |an "inte|
|00002e20| 72 65 73 74 69 6e 67 22 | 20 6d 61 74 63 68 2e 0a |resting"| match..|
|00002e30| 0a 20 20 20 20 20 20 20 | 20 48 65 72 65 27 73 20 |. | Here's |
|00002e40| 74 68 65 20 73 61 6d 65 | 20 65 78 61 6d 70 6c 65 |the same| example|
|00002e50| 20 61 73 20 62 65 66 6f | 72 65 2c 20 62 75 74 20 | as befo|re, but |
|00002e60| 63 6f 6e 73 69 64 65 72 | 69 6e 67 20 62 6c 61 6e |consider|ing blan|
|00002e70| 6b 73 20 74 6f 20 62 65 | 0a 20 20 20 20 20 20 20 |ks to be|. |
|00002e80| 20 6a 75 6e 6b 2e 20 20 | 54 68 61 74 20 70 72 65 | junk. |That pre|
|00002e90| 76 65 6e 74 73 20 22 20 | 61 62 63 64 22 20 66 72 |vents " |abcd" fr|
|00002ea0| 6f 6d 20 6d 61 74 63 68 | 69 6e 67 20 74 68 65 20 |om match|ing the |
|00002eb0| 22 20 61 62 63 64 22 20 | 61 74 20 74 68 65 20 74 |" abcd" |at the t|
|00002ec0| 61 69 6c 0a 20 20 20 20 | 20 20 20 20 65 6e 64 20 |ail. | end |
|00002ed0| 6f 66 20 74 68 65 20 73 | 65 63 6f 6e 64 20 73 65 |of the s|econd se|
|00002ee0| 71 75 65 6e 63 65 20 64 | 69 72 65 63 74 6c 79 2e |quence d|irectly.|
|00002ef0| 20 20 49 6e 73 74 65 61 | 64 20 6f 6e 6c 79 20 74 | Instea|d only t|
|00002f00| 68 65 20 22 61 62 63 64 | 22 20 63 61 6e 0a 20 20 |he "abcd|" can. |
|00002f10| 20 20 20 20 20 20 6d 61 | 74 63 68 2c 20 61 6e 64 | ma|tch, and|
|00002f20| 20 6d 61 74 63 68 65 73 | 20 74 68 65 20 6c 65 66 | matches| the lef|
|00002f30| 74 6d 6f 73 74 20 22 61 | 62 63 64 22 20 69 6e 20 |tmost "a|bcd" in |
|00002f40| 74 68 65 20 73 65 63 6f | 6e 64 20 73 65 71 75 65 |the seco|nd seque|
|00002f50| 6e 63 65 3a 0a 0a 20 20 | 20 20 20 20 20 20 3e 3e |nce:.. | >>|
|00002f60| 3e 20 73 20 3d 20 53 65 | 71 75 65 6e 63 65 4d 61 |> s = Se|quenceMa|
|00002f70| 74 63 68 65 72 28 6c 61 | 6d 62 64 61 20 78 3a 20 |tcher(la|mbda x: |
|00002f80| 78 3d 3d 22 20 22 2c 20 | 22 20 61 62 63 64 22 2c |x==" ", |" abcd",|
|00002f90| 20 22 61 62 63 64 20 61 | 62 63 64 22 29 0a 20 20 | "abcd a|bcd"). |
|00002fa0| 20 20 20 20 20 20 3e 3e | 3e 20 73 2e 66 69 6e 64 | >>|> s.find|
|00002fb0| 5f 6c 6f 6e 67 65 73 74 | 5f 6d 61 74 63 68 28 30 |_longest|_match(0|
|00002fc0| 2c 20 35 2c 20 30 2c 20 | 39 29 0a 20 20 20 20 20 |, 5, 0, |9). |
|00002fd0| 20 20 20 4d 61 74 63 68 | 28 61 3d 31 2c 20 62 3d | Match|(a=1, b=|
|00002fe0| 30 2c 20 73 69 7a 65 3d | 34 29 0a 0a 20 20 20 20 |0, size=|4).. |
|00002ff0| 20 20 20 20 49 66 20 6e | 6f 20 62 6c 6f 63 6b 73 | If n|o blocks|
|00003000| 20 6d 61 74 63 68 2c 20 | 72 65 74 75 72 6e 20 28 | match, |return (|
|00003010| 61 6c 6f 2c 20 62 6c 6f | 2c 20 30 29 2e 0a 0a 20 |alo, blo|, 0)... |
|00003020| 20 20 20 20 20 20 20 3e | 3e 3e 20 73 20 3d 20 53 | >|>> s = S|
|00003030| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 28 4e |equenceM|atcher(N|
|00003040| 6f 6e 65 2c 20 22 61 62 | 22 2c 20 22 63 22 29 0a |one, "ab|", "c").|
|00003050| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 73 2e 66 69 | |>>> s.fi|
|00003060| 6e 64 5f 6c 6f 6e 67 65 | 73 74 5f 6d 61 74 63 68 |nd_longe|st_match|
|00003070| 28 30 2c 20 32 2c 20 30 | 2c 20 31 29 0a 20 20 20 |(0, 2, 0|, 1). |
|00003080| 20 20 20 20 20 4d 61 74 | 63 68 28 61 3d 30 2c 20 | Mat|ch(a=0, |
|00003090| 62 3d 30 2c 20 73 69 7a | 65 3d 30 29 0a 20 20 20 |b=0, siz|e=0). |
|000030a0| 20 20 20 20 20 69 00 00 | 00 00 69 01 00 00 00 28 | i..|..i....(|
|000030b0| 07 00 00 00 52 13 00 00 | 00 52 14 00 00 00 52 1f |....R...|.R....R.|
|000030c0| 00 00 00 52 24 00 00 00 | 74 06 00 00 00 78 72 61 |...R$...|t....xra|
|000030d0| 6e 67 65 74 03 00 00 00 | 67 65 74 52 0a 00 00 00 |nget....|getR....|
|000030e0| 28 13 00 00 00 52 16 00 | 00 00 74 03 00 00 00 61 |(....R..|..t....a|
|000030f0| 6c 6f 74 03 00 00 00 61 | 68 69 74 03 00 00 00 62 |lot....a|hit....b|
|00003100| 6c 6f 74 03 00 00 00 62 | 68 69 52 13 00 00 00 52 |lot....b|hiR....R|
|00003110| 14 00 00 00 52 1f 00 00 | 00 52 24 00 00 00 74 05 |....R...|.R$...t.|
|00003120| 00 00 00 62 65 73 74 69 | 74 05 00 00 00 62 65 73 |...besti|t....bes|
|00003130| 74 6a 74 08 00 00 00 62 | 65 73 74 73 69 7a 65 74 |tjt....b|estsizet|
|00003140| 05 00 00 00 6a 32 6c 65 | 6e 74 07 00 00 00 6e 6f |....j2le|nt....no|
|00003150| 74 68 69 6e 67 52 28 00 | 00 00 74 08 00 00 00 6a |thingR(.|..t....j|
|00003160| 32 6c 65 6e 67 65 74 74 | 08 00 00 00 6e 65 77 6a |2lengett|....newj|
|00003170| 32 6c 65 6e 74 01 00 00 | 00 6a 74 01 00 00 00 6b |2lent...|.jt....k|
|00003180| 28 00 00 00 00 28 00 00 | 00 00 73 1d 00 00 00 2f |(....(..|..s..../|
|00003190| 75 73 72 2f 6c 69 62 2f | 70 79 74 68 6f 6e 32 2e |usr/lib/|python2.|
|000031a0| 36 2f 64 69 66 66 6c 69 | 62 2e 70 79 74 12 00 00 |6/diffli|b.pyt...|
|000031b0| 00 66 69 6e 64 5f 6c 6f | 6e 67 65 73 74 5f 6d 61 |.find_lo|ngest_ma|
|000031c0| 74 63 68 5f 01 00 00 73 | 4e 00 00 00 00 38 2a 01 |tch_...s|N....8*.|
|000031d0| 14 04 06 01 06 01 10 00 | 06 03 09 01 06 01 17 00 |........|........|
|000031e0| 06 02 0d 01 07 01 0d 01 | 05 01 1f 01 0d 01 2c 01 |........|......,.|
|000031f0| 0a 06 03 00 1a 01 16 01 | 1d 01 25 01 03 00 22 01 |........|..%...".|
|00003200| 16 01 1d 01 0f 09 03 00 | 1a 01 15 01 1d 01 25 01 |........|......%.|
|00003210| 03 00 22 01 15 01 1d 01 | 0f 02 63 01 00 00 00 14 |..".....|..c.....|
|00003220| 00 00 00 06 00 00 00 43 | 00 00 00 73 24 02 00 00 |.......C|...s$...|
|00003230| 7c 00 00 69 00 00 64 02 | 00 6a 09 00 6f 08 00 01 ||..i..d.|.j..o...|
|00003240| 7c 00 00 69 00 00 53 01 | 74 02 00 7c 00 00 69 03 ||..i..S.|t..|..i.|
|00003250| 00 83 01 00 74 02 00 7c | 00 00 69 04 00 83 01 00 |....t..||..i.....|
|00003260| 02 7d 01 00 7d 02 00 64 | 01 00 7c 01 00 64 01 00 |.}..}..d|..|..d..|
|00003270| 7c 02 00 66 04 00 67 01 | 00 7d 03 00 67 00 00 7d ||..f..g.|.}..g..}|
|00003280| 04 00 78 df 00 7c 03 00 | 6f d7 00 01 7c 03 00 69 |..x..|..|o...|..i|
|00003290| 05 00 83 00 00 5c 04 00 | 7d 05 00 7d 06 00 7d 07 |.....\..|}..}..}.|
|000032a0| 00 7d 08 00 7c 00 00 69 | 06 00 7c 05 00 7c 06 00 |.}..|..i|..|..|..|
|000032b0| 7c 07 00 7c 08 00 83 04 | 00 04 5c 03 00 7d 09 00 ||..|....|..\..}..|
|000032c0| 7d 0a 00 7d 0b 00 7d 0c | 00 7c 0b 00 6f 8f 00 01 |}..}..}.|.|..o...|
|000032d0| 7c 04 00 69 07 00 7c 0c | 00 83 01 00 01 7c 05 00 ||..i..|.|.....|..|
|000032e0| 7c 09 00 6a 00 00 6f 2a | 00 01 7c 07 00 7c 0a 00 ||..j..o*|..|..|..|
|000032f0| 6a 00 00 6f 1d 00 01 7c | 03 00 69 07 00 7c 05 00 |j..o...||..i..|..|
|00003300| 7c 09 00 7c 07 00 7c 0a | 00 66 04 00 83 01 00 01 ||..|..|.|.f......|
|00003310| 6e 01 00 01 7c 09 00 7c | 0b 00 17 7c 06 00 6a 00 |n...|..||...|..j.|
|00003320| 00 6f 36 00 01 7c 0a 00 | 7c 0b 00 17 7c 08 00 6a |.o6..|..||...|..j|
|00003330| 00 00 6f 25 00 01 7c 03 | 00 69 07 00 7c 09 00 7c |..o%..|.|.i..|..||
|00003340| 0b 00 17 7c 06 00 7c 0a | 00 7c 0b 00 17 7c 08 00 |...|..|.|.|...|..|
|00003350| 66 04 00 83 01 00 01 71 | 2f 01 01 71 55 00 01 71 |f......q|/..qU..q|
|00003360| 55 00 01 57 7c 04 00 69 | 08 00 83 00 00 01 64 01 |U..W|..i|......d.|
|00003370| 00 04 7d 0d 00 04 7d 0e | 00 7d 0f 00 67 00 00 7d |..}...}.|.}..g..}|
|00003380| 10 00 78 7c 00 7c 04 00 | 44 5d 74 00 5c 03 00 7d |..x|.|..|D]t.\..}|
|00003390| 11 00 7d 12 00 7d 13 00 | 7c 0d 00 7c 0f 00 17 7c |..}..}..||..|...||
|000033a0| 11 00 6a 02 00 6f 1f 00 | 01 7c 0e 00 7c 0f 00 17 |..j..o..|.|..|...|
|000033b0| 7c 12 00 6a 02 00 6f 0e | 00 01 7c 0f 00 7c 13 00 ||..j..o.|..|..|..|
|000033c0| 37 7d 0f 00 71 59 01 01 | 7c 0f 00 6f 1a 00 01 7c |7}..qY..||..o...||
|000033d0| 10 00 69 07 00 7c 0d 00 | 7c 0e 00 7c 0f 00 66 03 |..i..|..||..|..f.|
|000033e0| 00 83 01 00 01 6e 01 00 | 01 7c 11 00 7c 12 00 7c |.....n..|.|..|..||
|000033f0| 13 00 03 02 7d 0d 00 7d | 0e 00 7d 0f 00 71 59 01 |....}..}|..}..qY.|
|00003400| 57 7c 0f 00 6f 1a 00 01 | 7c 10 00 69 07 00 7c 0d |W|..o...||..i..|.|
|00003410| 00 7c 0e 00 7c 0f 00 66 | 03 00 83 01 00 01 6e 01 |.|..|..f|......n.|
|00003420| 00 01 7c 10 00 69 07 00 | 7c 01 00 7c 02 00 64 01 |..|..i..||..|..d.|
|00003430| 00 66 03 00 83 01 00 01 | 7c 10 00 7c 00 00 5f 00 |.f......||..|.._.|
|00003440| 00 74 09 00 74 0a 00 69 | 0b 00 7c 00 00 69 00 00 |.t..t..i|..|..i..|
|00003450| 83 02 00 53 28 03 00 00 | 00 73 0d 03 00 00 52 65 |...S(...|.s....Re|
|00003460| 74 75 72 6e 20 6c 69 73 | 74 20 6f 66 20 74 72 69 |turn lis|t of tri|
|00003470| 70 6c 65 73 20 64 65 73 | 63 72 69 62 69 6e 67 20 |ples des|cribing |
|00003480| 6d 61 74 63 68 69 6e 67 | 20 73 75 62 73 65 71 75 |matching| subsequ|
|00003490| 65 6e 63 65 73 2e 0a 0a | 20 20 20 20 20 20 20 20 |ences...| |
|000034a0| 45 61 63 68 20 74 72 69 | 70 6c 65 20 69 73 20 6f |Each tri|ple is o|
|000034b0| 66 20 74 68 65 20 66 6f | 72 6d 20 28 69 2c 20 6a |f the fo|rm (i, j|
|000034c0| 2c 20 6e 29 2c 20 61 6e | 64 20 6d 65 61 6e 73 20 |, n), an|d means |
|000034d0| 74 68 61 74 0a 20 20 20 | 20 20 20 20 20 61 5b 69 |that. | a[i|
|000034e0| 3a 69 2b 6e 5d 20 3d 3d | 20 62 5b 6a 3a 6a 2b 6e |:i+n] ==| b[j:j+n|
|000034f0| 5d 2e 20 20 54 68 65 20 | 74 72 69 70 6c 65 73 20 |]. The |triples |
|00003500| 61 72 65 20 6d 6f 6e 6f | 74 6f 6e 69 63 61 6c 6c |are mono|tonicall|
|00003510| 79 20 69 6e 63 72 65 61 | 73 69 6e 67 20 69 6e 0a |y increa|sing in.|
|00003520| 20 20 20 20 20 20 20 20 | 69 20 61 6e 64 20 69 6e | |i and in|
|00003530| 20 6a 2e 20 20 4e 65 77 | 20 69 6e 20 50 79 74 68 | j. New| in Pyth|
|00003540| 6f 6e 20 32 2e 35 2c 20 | 69 74 27 73 20 61 6c 73 |on 2.5, |it's als|
|00003550| 6f 20 67 75 61 72 61 6e | 74 65 65 64 20 74 68 61 |o guaran|teed tha|
|00003560| 74 20 69 66 0a 20 20 20 | 20 20 20 20 20 28 69 2c |t if. | (i,|
|00003570| 20 6a 2c 20 6e 29 20 61 | 6e 64 20 28 69 27 2c 20 | j, n) a|nd (i', |
|00003580| 6a 27 2c 20 6e 27 29 20 | 61 72 65 20 61 64 6a 61 |j', n') |are adja|
|00003590| 63 65 6e 74 20 74 72 69 | 70 6c 65 73 20 69 6e 20 |cent tri|ples in |
|000035a0| 74 68 65 20 6c 69 73 74 | 2c 20 61 6e 64 0a 20 20 |the list|, and. |
|000035b0| 20 20 20 20 20 20 74 68 | 65 20 73 65 63 6f 6e 64 | th|e second|
|000035c0| 20 69 73 20 6e 6f 74 20 | 74 68 65 20 6c 61 73 74 | is not |the last|
|000035d0| 20 74 72 69 70 6c 65 20 | 69 6e 20 74 68 65 20 6c | triple |in the l|
|000035e0| 69 73 74 2c 20 74 68 65 | 6e 20 69 2b 6e 20 21 3d |ist, the|n i+n !=|
|000035f0| 20 69 27 20 6f 72 0a 20 | 20 20 20 20 20 20 20 6a | i' or. | j|
|00003600| 2b 6e 20 21 3d 20 6a 27 | 2e 20 20 49 4f 57 2c 20 |+n != j'|. IOW, |
|00003610| 61 64 6a 61 63 65 6e 74 | 20 74 72 69 70 6c 65 73 |adjacent| triples|
|00003620| 20 6e 65 76 65 72 20 64 | 65 73 63 72 69 62 65 20 | never d|escribe |
|00003630| 61 64 6a 61 63 65 6e 74 | 20 65 71 75 61 6c 0a 20 |adjacent| equal. |
|00003640| 20 20 20 20 20 20 20 62 | 6c 6f 63 6b 73 2e 0a 0a | b|locks...|
|00003650| 20 20 20 20 20 20 20 20 | 54 68 65 20 6c 61 73 74 | |The last|
|00003660| 20 74 72 69 70 6c 65 20 | 69 73 20 61 20 64 75 6d | triple |is a dum|
|00003670| 6d 79 2c 20 28 6c 65 6e | 28 61 29 2c 20 6c 65 6e |my, (len|(a), len|
|00003680| 28 62 29 2c 20 30 29 2c | 20 61 6e 64 20 69 73 20 |(b), 0),| and is |
|00003690| 74 68 65 20 6f 6e 6c 79 | 0a 20 20 20 20 20 20 20 |the only|. |
|000036a0| 20 74 72 69 70 6c 65 20 | 77 69 74 68 20 6e 3d 3d | triple |with n==|
|000036b0| 30 2e 0a 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |0... | >>> |
|000036c0| 73 20 3d 20 53 65 71 75 | 65 6e 63 65 4d 61 74 63 |s = Sequ|enceMatc|
|000036d0| 68 65 72 28 4e 6f 6e 65 | 2c 20 22 61 62 78 63 64 |her(None|, "abxcd|
|000036e0| 22 2c 20 22 61 62 63 64 | 22 29 0a 20 20 20 20 20 |", "abcd|"). |
|000036f0| 20 20 20 3e 3e 3e 20 73 | 2e 67 65 74 5f 6d 61 74 | >>> s|.get_mat|
|00003700| 63 68 69 6e 67 5f 62 6c | 6f 63 6b 73 28 29 0a 20 |ching_bl|ocks(). |
|00003710| 20 20 20 20 20 20 20 5b | 4d 61 74 63 68 28 61 3d | [|Match(a=|
|00003720| 30 2c 20 62 3d 30 2c 20 | 73 69 7a 65 3d 32 29 2c |0, b=0, |size=2),|
|00003730| 20 4d 61 74 63 68 28 61 | 3d 33 2c 20 62 3d 32 2c | Match(a|=3, b=2,|
|00003740| 20 73 69 7a 65 3d 32 29 | 2c 20 4d 61 74 63 68 28 | size=2)|, Match(|
|00003750| 61 3d 35 2c 20 62 3d 34 | 2c 20 73 69 7a 65 3d 30 |a=5, b=4|, size=0|
|00003760| 29 5d 0a 20 20 20 20 20 | 20 20 20 69 00 00 00 00 |)]. | i....|
|00003770| 4e 28 0c 00 00 00 52 1a | 00 00 00 52 12 00 00 00 |N(....R.|...R....|
|00003780| 52 1e 00 00 00 52 13 00 | 00 00 52 14 00 00 00 74 |R....R..|..R....t|
|00003790| 03 00 00 00 70 6f 70 52 | 3d 00 00 00 52 21 00 00 |....popR|=...R!..|
|000037a0| 00 74 04 00 00 00 73 6f | 72 74 74 03 00 00 00 6d |.t....so|rtt....m|
|000037b0| 61 70 52 0a 00 00 00 74 | 05 00 00 00 5f 6d 61 6b |apR....t|...._mak|
|000037c0| 65 28 14 00 00 00 52 16 | 00 00 00 74 02 00 00 00 |e(....R.|...t....|
|000037d0| 6c 61 74 02 00 00 00 6c | 62 74 05 00 00 00 71 75 |lat....l|bt....qu|
|000037e0| 65 75 65 52 1a 00 00 00 | 52 30 00 00 00 52 31 00 |eueR....|R0...R1.|
|000037f0| 00 00 52 32 00 00 00 52 | 33 00 00 00 52 28 00 00 |..R2...R|3...R(..|
|00003800| 00 52 3b 00 00 00 52 3c | 00 00 00 74 01 00 00 00 |.R;...R<|...t....|
|00003810| 78 74 02 00 00 00 69 31 | 74 02 00 00 00 6a 31 74 |xt....i1|t....j1t|
|00003820| 02 00 00 00 6b 31 74 0c | 00 00 00 6e 6f 6e 5f 61 |....k1t.|...non_a|
|00003830| 64 6a 61 63 65 6e 74 74 | 02 00 00 00 69 32 74 02 |djacentt|....i2t.|
|00003840| 00 00 00 6a 32 74 02 00 | 00 00 6b 32 28 00 00 00 |...j2t..|..k2(...|
|00003850| 00 28 00 00 00 00 73 1d | 00 00 00 2f 75 73 72 2f |.(....s.|.../usr/|
|00003860| 6c 69 62 2f 70 79 74 68 | 6f 6e 32 2e 36 2f 64 69 |lib/pyth|on2.6/di|
|00003870| 66 66 6c 69 62 2e 70 79 | 74 13 00 00 00 67 65 74 |fflib.py|t....get|
|00003880| 5f 6d 61 74 63 68 69 6e | 67 5f 62 6c 6f 63 6b 73 |_matchin|g_blocks|
|00003890| cd 01 00 00 73 3c 00 00 | 00 00 13 10 01 08 01 1f |....s<..|........|
|000038a0| 08 15 01 06 01 03 00 07 | 01 18 01 25 04 07 01 0d |........|...%....|
|000038b0| 01 1a 01 1d 01 22 01 2e | 01 0a 05 0e 01 06 01 07 |....."..|........|
|000038c0| 00 0f 02 22 04 0e 05 07 | 01 1a 01 18 01 07 01 1a |..."....|........|
|000038d0| 02 16 01 09 01 63 01 00 | 00 00 08 00 00 00 07 00 |.....c..|........|
|000038e0| 00 00 43 00 00 00 73 0e | 01 00 00 7c 00 00 69 00 |..C...s.|...|..i.|
|000038f0| 00 64 07 00 6a 09 00 6f | 08 00 01 7c 00 00 69 00 |.d..j..o|...|..i.|
|00003900| 00 53 01 64 01 00 04 7d | 01 00 7d 02 00 67 00 00 |.S.d...}|..}..g..|
|00003910| 04 7c 00 00 5f 00 00 7d | 03 00 78 d8 00 7c 00 00 |.|.._..}|..x..|..|
|00003920| 69 02 00 83 00 00 44 5d | ca 00 5c 03 00 7d 04 00 |i.....D]|..\..}..|
|00003930| 7d 05 00 7d 06 00 64 02 | 00 7d 07 00 7c 01 00 7c |}..}..d.|.}..|..||
|00003940| 04 00 6a 00 00 6f 17 00 | 01 7c 02 00 7c 05 00 6a |..j..o..|.|..|..j|
|00003950| 00 00 6f 0a 00 01 64 03 | 00 7d 07 00 6e 2f 00 01 |..o...d.|.}..n/..|
|00003960| 7c 01 00 7c 04 00 6a 00 | 00 6f 0a 00 01 64 04 00 ||..|..j.|.o...d..|
|00003970| 7d 07 00 6e 18 00 01 7c | 02 00 7c 05 00 6a 00 00 |}..n...||..|..j..|
|00003980| 6f 0a 00 01 64 05 00 7d | 07 00 6e 01 00 01 7c 07 |o...d..}|..n...|.|
|00003990| 00 6f 20 00 01 7c 03 00 | 69 03 00 7c 07 00 7c 01 |.o ..|..|i..|..|.|
|000039a0| 00 7c 04 00 7c 02 00 7c | 05 00 66 05 00 83 01 00 |.|..|..||..f.....|
|000039b0| 01 6e 01 00 01 7c 04 00 | 7c 06 00 17 7c 05 00 7c |.n...|..||...|..||
|000039c0| 06 00 17 02 7d 01 00 7d | 02 00 7c 06 00 6f 20 00 |....}..}|..|..o .|
|000039d0| 01 7c 03 00 69 03 00 64 | 06 00 7c 04 00 7c 01 00 |.|..i..d|..|..|..|
|000039e0| 7c 05 00 7c 02 00 66 05 | 00 83 01 00 01 71 3c 00 ||..|..f.|.....q<.|
|000039f0| 01 71 3c 00 57 7c 03 00 | 53 28 08 00 00 00 73 5a |.q<.W|..|S(....sZ|
|00003a00| 04 00 00 52 65 74 75 72 | 6e 20 6c 69 73 74 20 6f |...Retur|n list o|
|00003a10| 66 20 35 2d 74 75 70 6c | 65 73 20 64 65 73 63 72 |f 5-tupl|es descr|
|00003a20| 69 62 69 6e 67 20 68 6f | 77 20 74 6f 20 74 75 72 |ibing ho|w to tur|
|00003a30| 6e 20 61 20 69 6e 74 6f | 20 62 2e 0a 0a 20 20 20 |n a into| b... |
|00003a40| 20 20 20 20 20 45 61 63 | 68 20 74 75 70 6c 65 20 | Eac|h tuple |
|00003a50| 69 73 20 6f 66 20 74 68 | 65 20 66 6f 72 6d 20 28 |is of th|e form (|
|00003a60| 74 61 67 2c 20 69 31 2c | 20 69 32 2c 20 6a 31 2c |tag, i1,| i2, j1,|
|00003a70| 20 6a 32 29 2e 20 20 54 | 68 65 20 66 69 72 73 74 | j2). T|he first|
|00003a80| 20 74 75 70 6c 65 0a 20 | 20 20 20 20 20 20 20 68 | tuple. | h|
|00003a90| 61 73 20 69 31 20 3d 3d | 20 6a 31 20 3d 3d 20 30 |as i1 ==| j1 == 0|
|00003aa0| 2c 20 61 6e 64 20 72 65 | 6d 61 69 6e 69 6e 67 20 |, and re|maining |
|00003ab0| 74 75 70 6c 65 73 20 68 | 61 76 65 20 69 31 20 3d |tuples h|ave i1 =|
|00003ac0| 3d 20 74 68 65 20 69 32 | 20 66 72 6f 6d 20 74 68 |= the i2| from th|
|00003ad0| 65 0a 20 20 20 20 20 20 | 20 20 74 75 70 6c 65 20 |e. | tuple |
|00003ae0| 70 72 65 63 65 64 69 6e | 67 20 69 74 2c 20 61 6e |precedin|g it, an|
|00003af0| 64 20 6c 69 6b 65 77 69 | 73 65 20 66 6f 72 20 6a |d likewi|se for j|
|00003b00| 31 20 3d 3d 20 74 68 65 | 20 70 72 65 76 69 6f 75 |1 == the| previou|
|00003b10| 73 20 6a 32 2e 0a 0a 20 | 20 20 20 20 20 20 20 54 |s j2... | T|
|00003b20| 68 65 20 74 61 67 73 20 | 61 72 65 20 73 74 72 69 |he tags |are stri|
|00003b30| 6e 67 73 2c 20 77 69 74 | 68 20 74 68 65 73 65 20 |ngs, wit|h these |
|00003b40| 6d 65 61 6e 69 6e 67 73 | 3a 0a 0a 20 20 20 20 20 |meanings|:.. |
|00003b50| 20 20 20 27 72 65 70 6c | 61 63 65 27 3a 20 20 61 | 'repl|ace': a|
|00003b60| 5b 69 31 3a 69 32 5d 20 | 73 68 6f 75 6c 64 20 62 |[i1:i2] |should b|
|00003b70| 65 20 72 65 70 6c 61 63 | 65 64 20 62 79 20 62 5b |e replac|ed by b[|
|00003b80| 6a 31 3a 6a 32 5d 0a 20 | 20 20 20 20 20 20 20 27 |j1:j2]. | '|
|00003b90| 64 65 6c 65 74 65 27 3a | 20 20 20 61 5b 69 31 3a |delete':| a[i1:|
|00003ba0| 69 32 5d 20 73 68 6f 75 | 6c 64 20 62 65 20 64 65 |i2] shou|ld be de|
|00003bb0| 6c 65 74 65 64 2e 0a 20 | 20 20 20 20 20 20 20 20 |leted.. | |
|00003bc0| 20 20 20 20 20 20 20 20 | 20 20 20 4e 6f 74 65 20 | | Note |
|00003bd0| 74 68 61 74 20 6a 31 3d | 3d 6a 32 20 69 6e 20 74 |that j1=|=j2 in t|
|00003be0| 68 69 73 20 63 61 73 65 | 2e 0a 20 20 20 20 20 20 |his case|.. |
|00003bf0| 20 20 27 69 6e 73 65 72 | 74 27 3a 20 20 20 62 5b | 'inser|t': b[|
|00003c00| 6a 31 3a 6a 32 5d 20 73 | 68 6f 75 6c 64 20 62 65 |j1:j2] s|hould be|
|00003c10| 20 69 6e 73 65 72 74 65 | 64 20 61 74 20 61 5b 69 | inserte|d at a[i|
|00003c20| 31 3a 69 31 5d 2e 0a 20 | 20 20 20 20 20 20 20 20 |1:i1].. | |
|00003c30| 20 20 20 20 20 20 20 20 | 20 20 20 4e 6f 74 65 20 | | Note |
|00003c40| 74 68 61 74 20 69 31 3d | 3d 69 32 20 69 6e 20 74 |that i1=|=i2 in t|
|00003c50| 68 69 73 20 63 61 73 65 | 2e 0a 20 20 20 20 20 20 |his case|.. |
|00003c60| 20 20 27 65 71 75 61 6c | 27 3a 20 20 20 20 61 5b | 'equal|': a[|
|00003c70| 69 31 3a 69 32 5d 20 3d | 3d 20 62 5b 6a 31 3a 6a |i1:i2] =|= b[j1:j|
|00003c80| 32 5d 0a 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |2].. | >>> |
|00003c90| 61 20 3d 20 22 71 61 62 | 78 63 64 22 0a 20 20 20 |a = "qab|xcd". |
|00003ca0| 20 20 20 20 20 3e 3e 3e | 20 62 20 3d 20 22 61 62 | >>>| b = "ab|
|00003cb0| 79 63 64 66 22 0a 20 20 | 20 20 20 20 20 20 3e 3e |ycdf". | >>|
|00003cc0| 3e 20 73 20 3d 20 53 65 | 71 75 65 6e 63 65 4d 61 |> s = Se|quenceMa|
|00003cd0| 74 63 68 65 72 28 4e 6f | 6e 65 2c 20 61 2c 20 62 |tcher(No|ne, a, b|
|00003ce0| 29 0a 20 20 20 20 20 20 | 20 20 3e 3e 3e 20 66 6f |). | >>> fo|
|00003cf0| 72 20 74 61 67 2c 20 69 | 31 2c 20 69 32 2c 20 6a |r tag, i|1, i2, j|
|00003d00| 31 2c 20 6a 32 20 69 6e | 20 73 2e 67 65 74 5f 6f |1, j2 in| s.get_o|
|00003d10| 70 63 6f 64 65 73 28 29 | 3a 0a 20 20 20 20 20 20 |pcodes()|:. |
|00003d20| 20 20 2e 2e 2e 20 20 20 | 20 70 72 69 6e 74 20 28 | ... | print (|
|00003d30| 22 25 37 73 20 61 5b 25 | 64 3a 25 64 5d 20 28 25 |"%7s a[%|d:%d] (%|
|00003d40| 73 29 20 62 5b 25 64 3a | 25 64 5d 20 28 25 73 29 |s) b[%d:|%d] (%s)|
|00003d50| 22 20 25 0a 20 20 20 20 | 20 20 20 20 2e 2e 2e 20 |" %. | ... |
|00003d60| 20 20 20 20 20 20 20 20 | 20 20 28 74 61 67 2c 20 | | (tag, |
|00003d70| 69 31 2c 20 69 32 2c 20 | 61 5b 69 31 3a 69 32 5d |i1, i2, |a[i1:i2]|
|00003d80| 2c 20 6a 31 2c 20 6a 32 | 2c 20 62 5b 6a 31 3a 6a |, j1, j2|, b[j1:j|
|00003d90| 32 5d 29 29 0a 20 20 20 | 20 20 20 20 20 20 64 65 |2])). | de|
|00003da0| 6c 65 74 65 20 61 5b 30 | 3a 31 5d 20 28 71 29 20 |lete a[0|:1] (q) |
|00003db0| 62 5b 30 3a 30 5d 20 28 | 29 0a 20 20 20 20 20 20 |b[0:0] (|). |
|00003dc0| 20 20 20 20 65 71 75 61 | 6c 20 61 5b 31 3a 33 5d | equa|l a[1:3]|
|00003dd0| 20 28 61 62 29 20 62 5b | 30 3a 32 5d 20 28 61 62 | (ab) b[|0:2] (ab|
|00003de0| 29 0a 20 20 20 20 20 20 | 20 20 72 65 70 6c 61 63 |). | replac|
|00003df0| 65 20 61 5b 33 3a 34 5d | 20 28 78 29 20 62 5b 32 |e a[3:4]| (x) b[2|
|00003e00| 3a 33 5d 20 28 79 29 0a | 20 20 20 20 20 20 20 20 |:3] (y).| |
|00003e10| 20 20 65 71 75 61 6c 20 | 61 5b 34 3a 36 5d 20 28 | equal |a[4:6] (|
|00003e20| 63 64 29 20 62 5b 33 3a | 35 5d 20 28 63 64 29 0a |cd) b[3:|5] (cd).|
|00003e30| 20 20 20 20 20 20 20 20 | 20 69 6e 73 65 72 74 20 | | insert |
|00003e40| 61 5b 36 3a 36 5d 20 28 | 29 20 62 5b 35 3a 36 5d |a[6:6] (|) b[5:6]|
|00003e50| 20 28 66 29 0a 20 20 20 | 20 20 20 20 20 69 00 00 | (f). | i..|
|00003e60| 00 00 52 10 00 00 00 74 | 07 00 00 00 72 65 70 6c |..R....t|....repl|
|00003e70| 61 63 65 74 06 00 00 00 | 64 65 6c 65 74 65 74 06 |acet....|deletet.|
|00003e80| 00 00 00 69 6e 73 65 72 | 74 74 05 00 00 00 65 71 |...inser|tt....eq|
|00003e90| 75 61 6c 4e 28 04 00 00 | 00 52 1b 00 00 00 52 12 |ualN(...|.R....R.|
|00003ea0| 00 00 00 52 4d 00 00 00 | 52 21 00 00 00 28 08 00 |...RM...|R!...(..|
|00003eb0| 00 00 52 16 00 00 00 52 | 28 00 00 00 52 3b 00 00 |..R....R|(...R;..|
|00003ec0| 00 74 06 00 00 00 61 6e | 73 77 65 72 74 02 00 00 |.t....an|swert...|
|00003ed0| 00 61 69 74 02 00 00 00 | 62 6a 74 04 00 00 00 73 |.ait....|bjt....s|
|00003ee0| 69 7a 65 74 03 00 00 00 | 74 61 67 28 00 00 00 00 |izet....|tag(....|
|00003ef0| 28 00 00 00 00 73 1d 00 | 00 00 2f 75 73 72 2f 6c |(....s..|../usr/l|
|00003f00| 69 62 2f 70 79 74 68 6f | 6e 32 2e 36 2f 64 69 66 |ib/pytho|n2.6/dif|
|00003f10| 66 6c 69 62 2e 70 79 74 | 0b 00 00 00 67 65 74 5f |flib.pyt|....get_|
|00003f20| 6f 70 63 6f 64 65 73 14 | 02 00 00 73 26 00 00 00 |opcodes.|...s&...|
|00003f30| 00 1d 10 01 08 01 0a 01 | 0d 01 0d 00 0f 06 06 01 |........|........|
|00003f40| 1a 01 0a 01 0d 01 0a 01 | 0d 01 0a 01 07 01 20 01 |........|...... .|
|00003f50| 15 03 07 01 24 01 69 03 | 00 00 00 63 02 00 00 00 |....$.i.|...c....|
|00003f60| 0a 00 00 00 0a 00 00 00 | 63 00 00 00 73 fd 01 00 |........|c...s...|
|00003f70| 00 7c 00 00 69 00 00 83 | 00 00 7d 02 00 7c 02 00 |.|..i...|..}..|..|
|00003f80| 70 0d 00 01 64 06 00 67 | 01 00 7d 02 00 6e 01 00 |p...d..g|..}..n..|
|00003f90| 01 7c 02 00 64 02 00 19 | 64 02 00 19 64 01 00 6a |.|..d...|d...d..j|
|00003fa0| 02 00 6f 50 00 01 7c 02 | 00 64 02 00 19 5c 05 00 |..oP..|.|.d...\..|
|00003fb0| 7d 03 00 7d 04 00 7d 05 | 00 7d 06 00 7d 07 00 7c |}..}..}.|.}..}..||
|00003fc0| 03 00 74 01 00 7c 04 00 | 7c 05 00 7c 01 00 18 83 |..t..|..||..|....|
|00003fd0| 02 00 7c 05 00 74 01 00 | 7c 06 00 7c 07 00 7c 01 |..|..t..||..|..|.|
|00003fe0| 00 18 83 02 00 7c 07 00 | 66 05 00 7c 02 00 64 02 |.....|..|f..|..d.|
|00003ff0| 00 3c 6e 01 00 01 7c 02 | 00 64 04 00 19 64 02 00 |.<n...|.|.d...d..|
|00004000| 19 64 01 00 6a 02 00 6f | 50 00 01 7c 02 00 64 04 |.d..j..o|P..|..d.|
|00004010| 00 19 5c 05 00 7d 03 00 | 7d 04 00 7d 05 00 7d 06 |..\..}..|}..}..}.|
|00004020| 00 7d 07 00 7c 03 00 7c | 04 00 74 02 00 7c 05 00 |.}..|..||..t..|..|
|00004030| 7c 04 00 7c 01 00 17 83 | 02 00 7c 06 00 74 02 00 ||..|....|..|..t..|
|00004040| 7c 07 00 7c 06 00 7c 01 | 00 17 83 02 00 66 05 00 ||..|..|.|.....f..|
|00004050| 7c 02 00 64 04 00 3c 6e | 01 00 01 7c 01 00 7c 01 ||..d..<n|...|..|.|
|00004060| 00 17 7d 08 00 67 00 00 | 7d 09 00 78 c3 00 7c 02 |..}..g..|}..x..|.|
|00004070| 00 44 5d bb 00 5c 05 00 | 7d 03 00 7d 04 00 7d 05 |.D]..\..|}..}..}.|
|00004080| 00 7d 06 00 7d 07 00 7c | 03 00 64 01 00 6a 02 00 |.}..}..||..d..j..|
|00004090| 6f 7d 00 01 7c 05 00 7c | 04 00 18 7c 08 00 6a 04 |o}..|..||...|..j.|
|000040a0| 00 6f 6c 00 01 7c 09 00 | 69 03 00 7c 03 00 7c 04 |.ol..|..|i..|..|.|
|000040b0| 00 74 02 00 7c 05 00 7c | 04 00 7c 01 00 17 83 02 |.t..|..||..|.....|
|000040c0| 00 7c 06 00 74 02 00 7c | 07 00 7c 06 00 7c 01 00 |.|..t..||..|..|..|
|000040d0| 17 83 02 00 66 05 00 83 | 01 00 01 7c 09 00 56 01 |....f...|...|..V.|
|000040e0| 67 00 00 7d 09 00 74 01 | 00 7c 04 00 7c 05 00 7c |g..}..t.|.|..|..||
|000040f0| 01 00 18 83 02 00 74 01 | 00 7c 06 00 7c 07 00 7c |......t.|.|..|..||
|00004100| 01 00 18 83 02 00 02 7d | 04 00 7d 06 00 6e 01 00 |.......}|..}..n..|
|00004110| 01 7c 09 00 69 03 00 7c | 03 00 7c 04 00 7c 05 00 |.|..i..||..|..|..|
|00004120| 7c 06 00 7c 07 00 66 05 | 00 83 01 00 01 71 01 01 ||..|..f.|.....q..|
|00004130| 57 7c 09 00 6f 32 00 01 | 74 04 00 7c 09 00 83 01 |W|..o2..|t..|....|
|00004140| 00 64 03 00 6a 02 00 6f | 12 00 01 7c 09 00 64 02 |.d..j..o|...|..d.|
|00004150| 00 19 64 02 00 19 64 01 | 00 6a 02 00 0c 6f 09 00 |..d...d.|.j...o..|
|00004160| 01 7c 09 00 56 01 6e 01 | 00 01 64 05 00 53 28 07 |.|..V.n.|..d..S(.|
|00004170| 00 00 00 73 d3 03 00 00 | 20 49 73 6f 6c 61 74 65 |...s....| Isolate|
|00004180| 20 63 68 61 6e 67 65 20 | 63 6c 75 73 74 65 72 73 | change |clusters|
|00004190| 20 62 79 20 65 6c 69 6d | 69 6e 61 74 69 6e 67 20 | by elim|inating |
|000041a0| 72 61 6e 67 65 73 20 77 | 69 74 68 20 6e 6f 20 63 |ranges w|ith no c|
|000041b0| 68 61 6e 67 65 73 2e 0a | 0a 20 20 20 20 20 20 20 |hanges..|. |
|000041c0| 20 52 65 74 75 72 6e 20 | 61 20 67 65 6e 65 72 61 | Return |a genera|
|000041d0| 74 6f 72 20 6f 66 20 67 | 72 6f 75 70 73 20 77 69 |tor of g|roups wi|
|000041e0| 74 68 20 75 70 74 6f 20 | 6e 20 6c 69 6e 65 73 20 |th upto |n lines |
|000041f0| 6f 66 20 63 6f 6e 74 65 | 78 74 2e 0a 20 20 20 20 |of conte|xt.. |
|00004200| 20 20 20 20 45 61 63 68 | 20 67 72 6f 75 70 20 69 | Each| group i|
|00004210| 73 20 69 6e 20 74 68 65 | 20 73 61 6d 65 20 66 6f |s in the| same fo|
|00004220| 72 6d 61 74 20 61 73 20 | 72 65 74 75 72 6e 65 64 |rmat as |returned|
|00004230| 20 62 79 20 67 65 74 5f | 6f 70 63 6f 64 65 73 28 | by get_|opcodes(|
|00004240| 29 2e 0a 0a 20 20 20 20 | 20 20 20 20 3e 3e 3e 20 |)... | >>> |
|00004250| 66 72 6f 6d 20 70 70 72 | 69 6e 74 20 69 6d 70 6f |from ppr|int impo|
|00004260| 72 74 20 70 70 72 69 6e | 74 0a 20 20 20 20 20 20 |rt pprin|t. |
|00004270| 20 20 3e 3e 3e 20 61 20 | 3d 20 6d 61 70 28 73 74 | >>> a |= map(st|
|00004280| 72 2c 20 72 61 6e 67 65 | 28 31 2c 34 30 29 29 0a |r, range|(1,40)).|
|00004290| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 62 20 3d 20 | |>>> b = |
|000042a0| 61 5b 3a 5d 0a 20 20 20 | 20 20 20 20 20 3e 3e 3e |a[:]. | >>>|
|000042b0| 20 62 5b 38 3a 38 5d 20 | 3d 20 5b 27 69 27 5d 20 | b[8:8] |= ['i'] |
|000042c0| 20 20 20 20 23 20 4d 61 | 6b 65 20 61 6e 20 69 6e | # Ma|ke an in|
|000042d0| 73 65 72 74 69 6f 6e 0a | 20 20 20 20 20 20 20 20 |sertion.| |
|000042e0| 3e 3e 3e 20 62 5b 32 30 | 5d 20 2b 3d 20 27 78 27 |>>> b[20|] += 'x'|
|000042f0| 20 20 20 20 20 20 20 23 | 20 4d 61 6b 65 20 61 20 | #| Make a |
|00004300| 72 65 70 6c 61 63 65 6d | 65 6e 74 0a 20 20 20 20 |replacem|ent. |
|00004310| 20 20 20 20 3e 3e 3e 20 | 62 5b 32 33 3a 32 38 5d | >>> |b[23:28]|
|00004320| 20 3d 20 5b 5d 20 20 20 | 20 20 20 23 20 4d 61 6b | = [] | # Mak|
|00004330| 65 20 61 20 64 65 6c 65 | 74 69 6f 6e 0a 20 20 20 |e a dele|tion. |
|00004340| 20 20 20 20 20 3e 3e 3e | 20 62 5b 33 30 5d 20 2b | >>>| b[30] +|
|00004350| 3d 20 27 79 27 20 20 20 | 20 20 20 20 23 20 4d 61 |= 'y' | # Ma|
|00004360| 6b 65 20 61 6e 6f 74 68 | 65 72 20 72 65 70 6c 61 |ke anoth|er repla|
|00004370| 63 65 6d 65 6e 74 0a 20 | 20 20 20 20 20 20 20 3e |cement. | >|
|00004380| 3e 3e 20 70 70 72 69 6e | 74 28 6c 69 73 74 28 53 |>> pprin|t(list(S|
|00004390| 65 71 75 65 6e 63 65 4d | 61 74 63 68 65 72 28 4e |equenceM|atcher(N|
|000043a0| 6f 6e 65 2c 61 2c 62 29 | 2e 67 65 74 5f 67 72 6f |one,a,b)|.get_gro|
|000043b0| 75 70 65 64 5f 6f 70 63 | 6f 64 65 73 28 29 29 29 |uped_opc|odes()))|
|000043c0| 0a 20 20 20 20 20 20 20 | 20 5b 5b 28 27 65 71 75 |. | [[('equ|
|000043d0| 61 6c 27 2c 20 35 2c 20 | 38 2c 20 35 2c 20 38 29 |al', 5, |8, 5, 8)|
|000043e0| 2c 20 28 27 69 6e 73 65 | 72 74 27 2c 20 38 2c 20 |, ('inse|rt', 8, |
|000043f0| 38 2c 20 38 2c 20 39 29 | 2c 20 28 27 65 71 75 61 |8, 8, 9)|, ('equa|
|00004400| 6c 27 2c 20 38 2c 20 31 | 31 2c 20 39 2c 20 31 32 |l', 8, 1|1, 9, 12|
|00004410| 29 5d 2c 0a 20 20 20 20 | 20 20 20 20 20 5b 28 27 |)],. | [('|
|00004420| 65 71 75 61 6c 27 2c 20 | 31 36 2c 20 31 39 2c 20 |equal', |16, 19, |
|00004430| 31 37 2c 20 32 30 29 2c | 0a 20 20 20 20 20 20 20 |17, 20),|. |
|00004440| 20 20 20 28 27 72 65 70 | 6c 61 63 65 27 2c 20 31 | ('rep|lace', 1|
|00004450| 39 2c 20 32 30 2c 20 32 | 30 2c 20 32 31 29 2c 0a |9, 20, 2|0, 21),.|
|00004460| 20 20 20 20 20 20 20 20 | 20 20 28 27 65 71 75 61 | | ('equa|
|00004470| 6c 27 2c 20 32 30 2c 20 | 32 32 2c 20 32 31 2c 20 |l', 20, |22, 21, |
|00004480| 32 33 29 2c 0a 20 20 20 | 20 20 20 20 20 20 20 28 |23),. | (|
|00004490| 27 64 65 6c 65 74 65 27 | 2c 20 32 32 2c 20 32 37 |'delete'|, 22, 27|
|000044a0| 2c 20 32 33 2c 20 32 33 | 29 2c 0a 20 20 20 20 20 |, 23, 23|),. |
|000044b0| 20 20 20 20 20 28 27 65 | 71 75 61 6c 27 2c 20 32 | ('e|qual', 2|
|000044c0| 37 2c 20 33 30 2c 20 32 | 33 2c 20 32 36 29 5d 2c |7, 30, 2|3, 26)],|
|000044d0| 0a 20 20 20 20 20 20 20 | 20 20 5b 28 27 65 71 75 |. | [('equ|
|000044e0| 61 6c 27 2c 20 33 31 2c | 20 33 34 2c 20 32 37 2c |al', 31,| 34, 27,|
|000044f0| 20 33 30 29 2c 0a 20 20 | 20 20 20 20 20 20 20 20 | 30),. | |
|00004500| 28 27 72 65 70 6c 61 63 | 65 27 2c 20 33 34 2c 20 |('replac|e', 34, |
|00004510| 33 35 2c 20 33 30 2c 20 | 33 31 29 2c 0a 20 20 20 |35, 30, |31),. |
|00004520| 20 20 20 20 20 20 20 28 | 27 65 71 75 61 6c 27 2c | (|'equal',|
|00004530| 20 33 35 2c 20 33 38 2c | 20 33 31 2c 20 33 34 29 | 35, 38,| 31, 34)|
|00004540| 5d 5d 0a 20 20 20 20 20 | 20 20 20 52 51 00 00 00 |]]. | RQ...|
|00004550| 69 00 00 00 00 69 01 00 | 00 00 69 ff ff ff ff 4e |i....i..|..i....N|
|00004560| 28 05 00 00 00 73 05 00 | 00 00 65 71 75 61 6c 69 |(....s..|..equali|
|00004570| 00 00 00 00 69 01 00 00 | 00 69 00 00 00 00 69 01 |....i...|.i....i.|
|00004580| 00 00 00 28 05 00 00 00 | 52 57 00 00 00 74 03 00 |...(....|RW...t..|
|00004590| 00 00 6d 61 78 74 03 00 | 00 00 6d 69 6e 52 21 00 |..maxt..|..minR!.|
|000045a0| 00 00 52 1e 00 00 00 28 | 0a 00 00 00 52 16 00 00 |..R....(|....R...|
|000045b0| 00 52 26 00 00 00 74 05 | 00 00 00 63 6f 64 65 73 |.R&...t.|...codes|
|000045c0| 52 56 00 00 00 52 46 00 | 00 00 52 4a 00 00 00 52 |RV...RF.|..RJ...R|
|000045d0| 47 00 00 00 52 4b 00 00 | 00 74 02 00 00 00 6e 6e |G...RK..|.t....nn|
|000045e0| 74 05 00 00 00 67 72 6f | 75 70 28 00 00 00 00 28 |t....gro|up(....(|
|000045f0| 00 00 00 00 73 1d 00 00 | 00 2f 75 73 72 2f 6c 69 |....s...|./usr/li|
|00004600| 62 2f 70 79 74 68 6f 6e | 32 2e 36 2f 64 69 66 66 |b/python|2.6/diff|
|00004610| 6c 69 62 2e 70 79 74 13 | 00 00 00 67 65 74 5f 67 |lib.pyt.|...get_g|
|00004620| 72 6f 75 70 65 64 5f 6f | 70 63 6f 64 65 73 4b 02 |rouped_o|pcodesK.|
|00004630| 00 00 73 2a 00 00 00 00 | 19 0c 01 07 01 0d 02 15 |..s*....|........|
|00004640| 01 19 01 37 01 15 01 19 | 01 37 02 0a 01 06 01 07 |...7....|.7......|
|00004650| 00 15 03 1e 01 36 01 05 | 01 06 01 2b 01 20 01 30 |.....6..|...+. .0|
|00004660| 01 63 01 00 00 00 02 00 | 00 00 05 00 00 00 43 00 |.c......|......C.|
|00004670| 00 00 73 3e 00 00 00 74 | 00 00 64 01 00 84 00 00 |..s>...t|..d.....|
|00004680| 7c 00 00 69 01 00 83 00 | 00 64 02 00 83 03 00 7d ||..i....|.d.....}|
|00004690| 01 00 74 02 00 7c 01 00 | 74 03 00 7c 00 00 69 04 |..t..|..|t..|..i.|
|000046a0| 00 83 01 00 74 03 00 7c | 00 00 69 05 00 83 01 00 |....t..||..i.....|
|000046b0| 17 83 02 00 53 28 03 00 | 00 00 73 d2 02 00 00 52 |....S(..|..s....R|
|000046c0| 65 74 75 72 6e 20 61 20 | 6d 65 61 73 75 72 65 20 |eturn a |measure |
|000046d0| 6f 66 20 74 68 65 20 73 | 65 71 75 65 6e 63 65 73 |of the s|equences|
|000046e0| 27 20 73 69 6d 69 6c 61 | 72 69 74 79 20 28 66 6c |' simila|rity (fl|
|000046f0| 6f 61 74 20 69 6e 20 5b | 30 2c 31 5d 29 2e 0a 0a |oat in [|0,1])...|
|00004700| 20 20 20 20 20 20 20 20 | 57 68 65 72 65 20 54 20 | |Where T |
|00004710| 69 73 20 74 68 65 20 74 | 6f 74 61 6c 20 6e 75 6d |is the t|otal num|
|00004720| 62 65 72 20 6f 66 20 65 | 6c 65 6d 65 6e 74 73 20 |ber of e|lements |
|00004730| 69 6e 20 62 6f 74 68 20 | 73 65 71 75 65 6e 63 65 |in both |sequence|
|00004740| 73 2c 20 61 6e 64 0a 20 | 20 20 20 20 20 20 20 4d |s, and. | M|
|00004750| 20 69 73 20 74 68 65 20 | 6e 75 6d 62 65 72 20 6f | is the |number o|
|00004760| 66 20 6d 61 74 63 68 65 | 73 2c 20 74 68 69 73 20 |f matche|s, this |
|00004770| 69 73 20 32 2e 30 2a 4d | 20 2f 20 54 2e 0a 20 20 |is 2.0*M| / T.. |
|00004780| 20 20 20 20 20 20 4e 6f | 74 65 20 74 68 61 74 20 | No|te that |
|00004790| 74 68 69 73 20 69 73 20 | 31 20 69 66 20 74 68 65 |this is |1 if the|
|000047a0| 20 73 65 71 75 65 6e 63 | 65 73 20 61 72 65 20 69 | sequenc|es are i|
|000047b0| 64 65 6e 74 69 63 61 6c | 2c 20 61 6e 64 20 30 20 |dentical|, and 0 |
|000047c0| 69 66 0a 20 20 20 20 20 | 20 20 20 74 68 65 79 20 |if. | they |
|000047d0| 68 61 76 65 20 6e 6f 74 | 68 69 6e 67 20 69 6e 20 |have not|hing in |
|000047e0| 63 6f 6d 6d 6f 6e 2e 0a | 0a 20 20 20 20 20 20 20 |common..|. |
|000047f0| 20 2e 72 61 74 69 6f 28 | 29 20 69 73 20 65 78 70 | .ratio(|) is exp|
|00004800| 65 6e 73 69 76 65 20 74 | 6f 20 63 6f 6d 70 75 74 |ensive t|o comput|
|00004810| 65 20 69 66 20 79 6f 75 | 20 68 61 76 65 6e 27 74 |e if you| haven't|
|00004820| 20 61 6c 72 65 61 64 79 | 20 63 6f 6d 70 75 74 65 | already| compute|
|00004830| 64 0a 20 20 20 20 20 20 | 20 20 2e 67 65 74 5f 6d |d. | .get_m|
|00004840| 61 74 63 68 69 6e 67 5f | 62 6c 6f 63 6b 73 28 29 |atching_|blocks()|
|00004850| 20 6f 72 20 2e 67 65 74 | 5f 6f 70 63 6f 64 65 73 | or .get|_opcodes|
|00004860| 28 29 2c 20 69 6e 20 77 | 68 69 63 68 20 63 61 73 |(), in w|hich cas|
|00004870| 65 20 79 6f 75 20 6d 61 | 79 0a 20 20 20 20 20 20 |e you ma|y. |
|00004880| 20 20 77 61 6e 74 20 74 | 6f 20 74 72 79 20 2e 71 | want t|o try .q|
|00004890| 75 69 63 6b 5f 72 61 74 | 69 6f 28 29 20 6f 72 20 |uick_rat|io() or |
|000048a0| 2e 72 65 61 6c 5f 71 75 | 69 63 6b 5f 72 61 74 69 |.real_qu|ick_rati|
|000048b0| 6f 28 29 20 66 69 72 73 | 74 20 74 6f 20 67 65 74 |o() firs|t to get|
|000048c0| 20 61 6e 0a 20 20 20 20 | 20 20 20 20 75 70 70 65 | an. | uppe|
|000048d0| 72 20 62 6f 75 6e 64 2e | 0a 0a 20 20 20 20 20 20 |r bound.|.. |
|000048e0| 20 20 3e 3e 3e 20 73 20 | 3d 20 53 65 71 75 65 6e | >>> s |= Sequen|
|000048f0| 63 65 4d 61 74 63 68 65 | 72 28 4e 6f 6e 65 2c 20 |ceMatche|r(None, |
|00004900| 22 61 62 63 64 22 2c 20 | 22 62 63 64 65 22 29 0a |"abcd", |"bcde").|
|00004910| 20 20 20 20 20 20 20 20 | 3e 3e 3e 20 73 2e 72 61 | |>>> s.ra|
|00004920| 74 69 6f 28 29 0a 20 20 | 20 20 20 20 20 20 30 2e |tio(). | 0.|
|00004930| 37 35 0a 20 20 20 20 20 | 20 20 20 3e 3e 3e 20 73 |75. | >>> s|
|00004940| 2e 71 75 69 63 6b 5f 72 | 61 74 69 6f 28 29 0a 20 |.quick_r|atio(). |
|00004950| 20 20 20 20 20 20 20 30 | 2e 37 35 0a 20 20 20 20 | 0|.75. |
|00004960| 20 20 20 20 3e 3e 3e 20 | 73 2e 72 65 61 6c 5f 71 | >>> |s.real_q|
|00004970| 75 69 63 6b 5f 72 61 74 | 69 6f 28 29 0a 20 20 20 |uick_rat|io(). |
|00004980| 20 20 20 20 20 31 2e 30 | 0a 20 20 20 20 20 20 20 | 1.0|. |
|00004990| 20 63 02 00 00 00 02 00 | 00 00 03 00 00 00 53 00 | c......|......S.|
|000049a0| 00 00 73 0c 00 00 00 7c | 00 00 7c 01 00 64 00 00 |..s....||..|..d..|
|000049b0| 19 17 53 28 01 00 00 00 | 69 ff ff ff ff 28 00 00 |..S(....|i....(..|
|000049c0| 00 00 28 02 00 00 00 74 | 03 00 00 00 73 75 6d 74 |..(....t|....sumt|
|000049d0| 06 00 00 00 74 72 69 70 | 6c 65 28 00 00 00 00 28 |....trip|le(....(|
|000049e0| 00 00 00 00 73 1d 00 00 | 00 2f 75 73 72 2f 6c 69 |....s...|./usr/li|
|000049f0| 62 2f 70 79 74 68 6f 6e | 32 2e 36 2f 64 69 66 66 |b/python|2.6/diff|
|00004a00| 6c 69 62 2e 70 79 74 08 | 00 00 00 3c 6c 61 6d 62 |lib.pyt.|...<lamb|
|00004a10| 64 61 3e 93 02 00 00 73 | 00 00 00 00 69 00 00 00 |da>....s|....i...|
|00004a20| 00 28 06 00 00 00 52 0c | 00 00 00 52 4d 00 00 00 |.(....R.|...RM...|
|00004a30| 52 0f 00 00 00 52 1e 00 | 00 00 52 13 00 00 00 52 |R....R..|..R....R|
|00004a40| 14 00 00 00 28 02 00 00 | 00 52 16 00 00 00 52 0d |....(...|.R....R.|
|00004a50| 00 00 00 28 00 00 00 00 | 28 00 00 00 00 73 1d 00 |...(....|(....s..|
|00004a60| 00 00 2f 75 73 72 2f 6c | 69 62 2f 70 79 74 68 6f |../usr/l|ib/pytho|
|00004a70| 6e 32 2e 36 2f 64 69 66 | 66 6c 69 62 2e 70 79 74 |n2.6/dif|flib.pyt|
|00004a80| 05 00 00 00 72 61 74 69 | 6f 7d 02 00 00 73 06 00 |....rati|o}...s..|
|00004a90| 00 00 00 16 09 01 12 01 | 63 01 00 00 00 07 00 00 |........|c.......|
|00004aa0| 00 09 00 00 00 43 00 00 | 00 73 fb 00 00 00 7c 00 |.....C..|.s....|.|
|00004ab0| 00 69 00 00 64 03 00 6a | 08 00 6f 3f 00 01 68 00 |.i..d..j|..o?..h.|
|00004ac0| 00 04 7c 00 00 5f 00 00 | 7d 01 00 78 2f 00 7c 00 |..|.._..|}..x/.|.|
|00004ad0| 00 69 02 00 44 5d 20 00 | 7d 02 00 7c 01 00 69 03 |.i..D] .|}..|..i.|
|00004ae0| 00 7c 02 00 64 01 00 83 | 02 00 64 02 00 17 7c 01 |.|..d...|..d...|.|
|00004af0| 00 7c 02 00 3c 71 27 00 | 57 6e 01 00 01 7c 00 00 |.|..<q'.|Wn...|..|
|00004b00| 69 00 00 7d 01 00 68 00 | 00 7d 03 00 7c 03 00 69 |i..}..h.|.}..|..i|
|00004b10| 04 00 64 01 00 02 7d 04 | 00 7d 05 00 78 67 00 7c |..d...}.|.}..xg.||
|00004b20| 00 00 69 05 00 44 5d 5c | 00 7d 02 00 7c 04 00 7c |..i..D]\|.}..|..||
|00004b30| 02 00 83 01 00 6f 0e 00 | 01 7c 03 00 7c 02 00 19 |.....o..|.|..|...|
|00004b40| 7d 06 00 6e 13 00 01 7c | 01 00 69 03 00 7c 02 00 |}..n...||..i..|..|
|00004b50| 64 01 00 83 02 00 7d 06 | 00 7c 06 00 64 02 00 18 |d.....}.|.|..d...|
|00004b60| 7c 03 00 7c 02 00 3c 7c | 06 00 64 01 00 6a 04 00 ||..|..<||..d..j..|
|00004b70| 6f 0e 00 01 7c 05 00 64 | 02 00 17 7d 05 00 71 78 |o...|..d|...}..qx|
|00004b80| 00 01 71 78 00 57 74 06 | 00 7c 05 00 74 07 00 7c |..qx.Wt.|.|..t..||
|00004b90| 00 00 69 05 00 83 01 00 | 74 07 00 7c 00 00 69 02 |..i.....|t..|..i.|
|00004ba0| 00 83 01 00 17 83 02 00 | 53 28 04 00 00 00 73 a9 |........|S(....s.|
|00004bb0| 00 00 00 52 65 74 75 72 | 6e 20 61 6e 20 75 70 70 |...Retur|n an upp|
|00004bc0| 65 72 20 62 6f 75 6e 64 | 20 6f 6e 20 72 61 74 69 |er bound| on rati|
|00004bd0| 6f 28 29 20 72 65 6c 61 | 74 69 76 65 6c 79 20 71 |o() rela|tively q|
|00004be0| 75 69 63 6b 6c 79 2e 0a | 0a 20 20 20 20 20 20 20 |uickly..|. |
|00004bf0| 20 54 68 69 73 20 69 73 | 6e 27 74 20 64 65 66 69 | This is|n't defi|
|00004c00| 6e 65 64 20 62 65 79 6f | 6e 64 20 74 68 61 74 20 |ned beyo|nd that |
|00004c10| 69 74 20 69 73 20 61 6e | 20 75 70 70 65 72 20 62 |it is an| upper b|
|00004c20| 6f 75 6e 64 20 6f 6e 20 | 2e 72 61 74 69 6f 28 29 |ound on |.ratio()|
|00004c30| 2c 20 61 6e 64 0a 20 20 | 20 20 20 20 20 20 69 73 |, and. | is|
|00004c40| 20 66 61 73 74 65 72 20 | 74 6f 20 63 6f 6d 70 75 | faster |to compu|
|00004c50| 74 65 2e 0a 20 20 20 20 | 20 20 20 20 69 00 00 00 |te.. | i...|
|00004c60| 00 69 01 00 00 00 4e 28 | 08 00 00 00 52 1c 00 00 |.i....N(|....R...|
|00004c70| 00 52 12 00 00 00 52 14 | 00 00 00 52 2f 00 00 00 |.R....R.|...R/...|
|00004c80| 52 23 00 00 00 52 13 00 | 00 00 52 0f 00 00 00 52 |R#...R..|..R....R|
|00004c90| 1e 00 00 00 28 07 00 00 | 00 52 16 00 00 00 52 1c |....(...|.R....R.|
|00004ca0| 00 00 00 52 29 00 00 00 | 74 05 00 00 00 61 76 61 |...R)...|t....ava|
|00004cb0| 69 6c 74 08 00 00 00 61 | 76 61 69 6c 68 61 73 52 |ilt....a|vailhasR|
|00004cc0| 0d 00 00 00 74 04 00 00 | 00 6e 75 6d 62 28 00 00 |....t...|.numb(..|
|00004cd0| 00 00 28 00 00 00 00 73 | 1d 00 00 00 2f 75 73 72 |..(....s|..../usr|
|00004ce0| 2f 6c 69 62 2f 70 79 74 | 68 6f 6e 32 2e 36 2f 64 |/lib/pyt|hon2.6/d|
|00004cf0| 69 66 66 6c 69 62 2e 70 | 79 74 0b 00 00 00 71 75 |ifflib.p|yt....qu|
|00004d00| 69 63 6b 5f 72 61 74 69 | 6f 97 02 00 00 73 22 00 |ick_rati|o....s".|
|00004d10| 00 00 00 0a 10 01 0d 01 | 0a 00 06 01 22 01 09 03 |........|...."...|
|00004d20| 06 01 10 01 0a 00 06 01 | 0d 01 0e 02 12 01 0e 01 |........|........|
|00004d30| 0d 01 12 01 63 01 00 00 | 00 03 00 00 00 04 00 00 |....c...|........|
|00004d40| 00 43 00 00 00 73 39 00 | 00 00 74 00 00 7c 00 00 |.C...s9.|..t..|..|
|00004d50| 69 01 00 83 01 00 74 00 | 00 7c 00 00 69 02 00 83 |i.....t.|.|..i...|
|00004d60| 01 00 02 7d 01 00 7d 02 | 00 74 03 00 74 04 00 7c |...}..}.|.t..t..||
|00004d70| 01 00 7c 02 00 83 02 00 | 7c 01 00 7c 02 00 17 83 |..|.....||..|....|
|00004d80| 02 00 53 28 01 00 00 00 | 73 ca 00 00 00 52 65 74 |..S(....|s....Ret|
|00004d90| 75 72 6e 20 61 6e 20 75 | 70 70 65 72 20 62 6f 75 |urn an u|pper bou|
|00004da0| 6e 64 20 6f 6e 20 72 61 | 74 69 6f 28 29 20 76 65 |nd on ra|tio() ve|
|00004db0| 72 79 20 71 75 69 63 6b | 6c 79 2e 0a 0a 20 20 20 |ry quick|ly... |
|00004dc0| 20 20 20 20 20 54 68 69 | 73 20 69 73 6e 27 74 20 | Thi|s isn't |
|00004dd0| 64 65 66 69 6e 65 64 20 | 62 65 79 6f 6e 64 20 74 |defined |beyond t|
|00004de0| 68 61 74 20 69 74 20 69 | 73 20 61 6e 20 75 70 70 |hat it i|s an upp|
|00004df0| 65 72 20 62 6f 75 6e 64 | 20 6f 6e 20 2e 72 61 74 |er bound| on .rat|
|00004e00| 69 6f 28 29 2c 20 61 6e | 64 0a 20 20 20 20 20 20 |io(), an|d. |
|00004e10| 20 20 69 73 20 66 61 73 | 74 65 72 20 74 6f 20 63 | is fas|ter to c|
|00004e20| 6f 6d 70 75 74 65 20 74 | 68 61 6e 20 65 69 74 68 |ompute t|han eith|
|00004e30| 65 72 20 2e 72 61 74 69 | 6f 28 29 20 6f 72 20 2e |er .rati|o() or .|
|00004e40| 71 75 69 63 6b 5f 72 61 | 74 69 6f 28 29 2e 0a 20 |quick_ra|tio().. |
|00004e50| 20 20 20 20 20 20 20 28 | 05 00 00 00 52 1e 00 00 | (|....R...|
|00004e60| 00 52 13 00 00 00 52 14 | 00 00 00 52 0f 00 00 00 |.R....R.|...R....|
|00004e70| 52 59 00 00 00 28 03 00 | 00 00 52 16 00 00 00 52 |RY...(..|..R....R|
|00004e80| 42 00 00 00 52 43 00 00 | 00 28 00 00 00 00 28 00 |B...RC..|.(....(.|
|00004e90| 00 00 00 73 1d 00 00 00 | 2f 75 73 72 2f 6c 69 62 |...s....|/usr/lib|
|00004ea0| 2f 70 79 74 68 6f 6e 32 | 2e 36 2f 64 69 66 66 6c |/python2|.6/diffl|
|00004eb0| 69 62 2e 70 79 74 10 00 | 00 00 72 65 61 6c 5f 71 |ib.pyt..|..real_q|
|00004ec0| 75 69 63 6b 5f 72 61 74 | 69 6f b4 02 00 00 73 04 |uick_rat|io....s.|
|00004ed0| 00 00 00 00 07 1f 03 4e | 28 10 00 00 00 74 08 00 |.......N|(....t..|
|00004ee0| 00 00 5f 5f 6e 61 6d 65 | 5f 5f 74 0a 00 00 00 5f |..__name|__t...._|
|00004ef0| 5f 6d 6f 64 75 6c 65 5f | 5f 74 07 00 00 00 5f 5f |_module_|_t....__|
|00004f00| 64 6f 63 5f 5f 52 12 00 | 00 00 52 17 00 00 00 52 |doc__R..|..R....R|
|00004f10| 15 00 00 00 52 18 00 00 | 00 52 19 00 00 00 52 1d |....R...|.R....R.|
|00004f20| 00 00 00 52 3d 00 00 00 | 52 4d 00 00 00 52 57 00 |...R=...|RM...RW.|
|00004f30| 00 00 52 5d 00 00 00 52 | 61 00 00 00 52 65 00 00 |..R]...R|a...Re..|
|00004f40| 00 52 66 00 00 00 28 00 | 00 00 00 28 00 00 00 00 |.Rf...(.|...(....|
|00004f50| 28 00 00 00 00 73 1d 00 | 00 00 2f 75 73 72 2f 6c |(....s..|../usr/l|
|00004f60| 69 62 2f 70 79 74 68 6f | 6e 32 2e 36 2f 64 69 66 |ib/pytho|n2.6/dif|
|00004f70| 66 6c 69 62 2e 70 79 52 | 03 00 00 00 2e 00 00 00 |flib.pyR|........|
|00004f80| 73 1a 00 00 00 06 6a 06 | 02 12 3f 09 0c 09 1a 09 |s.....j.|..?.....|
|00004f90| 2d 09 33 09 6e 09 47 09 | 37 0c 32 09 1a 09 1d 69 |-.3.n.G.|7.2....i|
|00004fa0| 03 00 00 00 67 33 33 33 | 33 33 33 e3 3f 63 04 00 |....g333|333.?c..|
|00004fb0| 00 00 09 00 00 00 06 00 | 00 00 43 00 00 00 73 20 |........|..C...s |
|00004fc0| 01 00 00 7c 02 00 64 01 | 00 6a 04 00 70 17 00 01 |...|..d.|.j..p...|
|00004fd0| 74 00 00 64 02 00 7c 02 | 00 66 01 00 16 83 01 00 |t..d..|.|.f......|
|00004fe0| 82 01 00 6e 01 00 01 64 | 03 00 7c 03 00 04 03 6a |...n...d|..|....j|
|00004ff0| 01 00 6f 0a 00 01 64 04 | 00 6a 01 00 6e 02 00 02 |..o...d.|.j..n...|
|00005000| 01 70 17 00 01 74 00 00 | 64 05 00 7c 03 00 66 01 |.p...t..|d..|..f.|
|00005010| 00 16 83 01 00 82 01 00 | 6e 01 00 01 67 00 00 7d |........|n...g..}|
|00005020| 04 00 74 01 00 83 00 00 | 7d 05 00 7c 05 00 69 02 |..t.....|}..|..i.|
|00005030| 00 7c 00 00 83 01 00 01 | 78 71 00 7c 01 00 44 5d |.|......|xq.|..D]|
|00005040| 69 00 7d 06 00 7c 05 00 | 69 03 00 7c 06 00 83 01 |i.}..|..|i..|....|
|00005050| 00 01 7c 05 00 69 04 00 | 83 00 00 7c 03 00 6a 05 |..|..i..|...|..j.|
|00005060| 00 6f 43 00 01 7c 05 00 | 69 05 00 83 00 00 7c 03 |.oC..|..|i.....|.|
|00005070| 00 6a 05 00 6f 30 00 01 | 7c 05 00 69 06 00 83 00 |.j..o0..||..i....|
|00005080| 00 7c 03 00 6a 05 00 6f | 1d 00 01 7c 04 00 69 07 |.|..j..o|...|..i.|
|00005090| 00 7c 05 00 69 06 00 83 | 00 00 7c 06 00 66 02 00 |.|..i...|..|..f..|
|000050a0| 83 01 00 01 71 7c 00 01 | 71 7c 00 57 74 08 00 69 |....q|..|q|.Wt..i|
|000050b0| 09 00 7c 02 00 7c 04 00 | 83 02 00 7d 04 00 67 00 |..|..|..|...}..g.|
|000050c0| 00 04 7d 07 00 7c 04 00 | 44 5d 13 00 5c 02 00 7d |..}..|..|D]..\..}|
|000050d0| 08 00 7d 06 00 7c 07 00 | 7c 06 00 12 71 06 01 7e |..}..|..||...q..~|
|000050e0| 07 00 53 28 06 00 00 00 | 73 c7 03 00 00 55 73 65 |..S(....|s....Use|
|000050f0| 20 53 65 71 75 65 6e 63 | 65 4d 61 74 63 68 65 72 | Sequenc|eMatcher|
|00005100| 20 74 6f 20 72 65 74 75 | 72 6e 20 6c 69 73 74 20 | to retu|rn list |
|00005110| 6f 66 20 74 68 65 20 62 | 65 73 74 20 22 67 6f 6f |of the b|est "goo|
|00005120| 64 20 65 6e 6f 75 67 68 | 22 20 6d 61 74 63 68 65 |d enough|" matche|
|00005130| 73 2e 0a 0a 20 20 20 20 | 77 6f 72 64 20 69 73 20 |s... |word is |
|00005140| 61 20 73 65 71 75 65 6e | 63 65 20 66 6f 72 20 77 |a sequen|ce for w|
|00005150| 68 69 63 68 20 63 6c 6f | 73 65 20 6d 61 74 63 68 |hich clo|se match|
|00005160| 65 73 20 61 72 65 20 64 | 65 73 69 72 65 64 20 28 |es are d|esired (|
|00005170| 74 79 70 69 63 61 6c 6c | 79 20 61 0a 20 20 20 20 |typicall|y a. |
|00005180| 73 74 72 69 6e 67 29 2e | 0a 0a 20 20 20 20 70 6f |string).|.. po|
|00005190| 73 73 69 62 69 6c 69 74 | 69 65 73 20 69 73 20 61 |ssibilit|ies is a|
|000051a0| 20 6c 69 73 74 20 6f 66 | 20 73 65 71 75 65 6e 63 | list of| sequenc|
|000051b0| 65 73 20 61 67 61 69 6e | 73 74 20 77 68 69 63 68 |es again|st which|
|000051c0| 20 74 6f 20 6d 61 74 63 | 68 20 77 6f 72 64 0a 20 | to matc|h word. |
|000051d0| 20 20 20 28 74 79 70 69 | 63 61 6c 6c 79 20 61 20 | (typi|cally a |
|000051e0| 6c 69 73 74 20 6f 66 20 | 73 74 72 69 6e 67 73 29 |list of |strings)|
|000051f0| 2e 0a 0a 20 20 20 20 4f | 70 74 69 6f 6e 61 6c 20 |... O|ptional |
|00005200| 61 72 67 20 6e 20 28 64 | 65 66 61 75 6c 74 20 33 |arg n (d|efault 3|
|00005210| 29 20 69 73 20 74 68 65 | 20 6d 61 78 69 6d 75 6d |) is the| maximum|
|00005220| 20 6e 75 6d 62 65 72 20 | 6f 66 20 63 6c 6f 73 65 | number |of close|
|00005230| 20 6d 61 74 63 68 65 73 | 20 74 6f 0a 20 20 20 20 | matches| to. |
|00005240| 72 65 74 75 72 6e 2e 20 | 20 6e 20 6d 75 73 74 20 |return. | n must |
|00005250| 62 65 20 3e 20 30 2e 0a | 0a 20 20 20 20 4f 70 74 |be > 0..|. Opt|
|00005260| 69 6f 6e 61 6c 20 61 72 | 67 20 63 75 74 6f 66 66 |ional ar|g cutoff|
|00005270| 20 28 64 65 66 61 75 6c | 74 20 30 2e 36 29 20 69 | (defaul|t 0.6) i|
|00005280| 73 20 61 20 66 6c 6f 61 | 74 20 69 6e 20 5b 30 2c |s a floa|t in [0,|
|00005290| 20 31 5d 2e 20 20 50 6f | 73 73 69 62 69 6c 69 74 | 1]. Po|ssibilit|
|000052a0| 69 65 73 0a 20 20 20 20 | 74 68 61 74 20 64 6f 6e |ies. |that don|
|000052b0| 27 74 20 73 63 6f 72 65 | 20 61 74 20 6c 65 61 73 |'t score| at leas|
|000052c0| 74 20 74 68 61 74 20 73 | 69 6d 69 6c 61 72 20 74 |t that s|imilar t|
|000052d0| 6f 20 77 6f 72 64 20 61 | 72 65 20 69 67 6e 6f 72 |o word a|re ignor|
|000052e0| 65 64 2e 0a 0a 20 20 20 | 20 54 68 65 20 62 65 73 |ed... | The bes|
|000052f0| 74 20 28 6e 6f 20 6d 6f | 72 65 20 74 68 61 6e 20 |t (no mo|re than |
|00005300| 6e 29 20 6d 61 74 63 68 | 65 73 20 61 6d 6f 6e 67 |n) match|es among|
|00005310| 20 74 68 65 20 70 6f 73 | 73 69 62 69 6c 69 74 69 | the pos|sibiliti|
|00005320| 65 73 20 61 72 65 20 72 | 65 74 75 72 6e 65 64 0a |es are r|eturned.|
|00005330| 20 20 20 20 69 6e 20 61 | 20 6c 69 73 74 2c 20 73 | in a| list, s|
|00005340| 6f 72 74 65 64 20 62 79 | 20 73 69 6d 69 6c 61 72 |orted by| similar|
|00005350| 69 74 79 20 73 63 6f 72 | 65 2c 20 6d 6f 73 74 20 |ity scor|e, most |
|00005360| 73 69 6d 69 6c 61 72 20 | 66 69 72 73 74 2e 0a 0a |similar |first...|
|00005370| 20 20 20 20 3e 3e 3e 20 | 67 65 74 5f 63 6c 6f 73 | >>> |get_clos|
|00005380| 65 5f 6d 61 74 63 68 65 | 73 28 22 61 70 70 65 6c |e_matche|s("appel|
|00005390| 22 2c 20 5b 22 61 70 65 | 22 2c 20 22 61 70 70 6c |", ["ape|", "appl|
|000053a0| 65 22 2c 20 22 70 65 61 | 63 68 22 2c 20 22 70 75 |e", "pea|ch", "pu|
|000053b0| 70 70 79 22 5d 29 0a 20 | 20 20 20 5b 27 61 70 70 |ppy"]). | ['app|
|000053c0| 6c 65 27 2c 20 27 61 70 | 65 27 5d 0a 20 20 20 20 |le', 'ap|e']. |
|000053d0| 3e 3e 3e 20 69 6d 70 6f | 72 74 20 6b 65 79 77 6f |>>> impo|rt keywo|
|000053e0| 72 64 20 61 73 20 5f 6b | 65 79 77 6f 72 64 0a 20 |rd as _k|eyword. |
|000053f0| 20 20 20 3e 3e 3e 20 67 | 65 74 5f 63 6c 6f 73 65 | >>> g|et_close|
|00005400| 5f 6d 61 74 63 68 65 73 | 28 22 77 68 65 65 6c 22 |_matches|("wheel"|
|00005410| 2c 20 5f 6b 65 79 77 6f | 72 64 2e 6b 77 6c 69 73 |, _keywo|rd.kwlis|
|00005420| 74 29 0a 20 20 20 20 5b | 27 77 68 69 6c 65 27 5d |t). [|'while']|
|00005430| 0a 20 20 20 20 3e 3e 3e | 20 67 65 74 5f 63 6c 6f |. >>>| get_clo|
|00005440| 73 65 5f 6d 61 74 63 68 | 65 73 28 22 61 70 70 6c |se_match|es("appl|
|00005450| 65 22 2c 20 5f 6b 65 79 | 77 6f 72 64 2e 6b 77 6c |e", _key|word.kwl|
|00005460| 69 73 74 29 0a 20 20 20 | 20 5b 5d 0a 20 20 20 20 |ist). | []. |
|00005470| 3e 3e 3e 20 67 65 74 5f | 63 6c 6f 73 65 5f 6d 61 |>>> get_|close_ma|
|00005480| 74 63 68 65 73 28 22 61 | 63 63 65 70 74 22 2c 20 |tches("a|ccept", |
|00005490| 5f 6b 65 79 77 6f 72 64 | 2e 6b 77 6c 69 73 74 29 |_keyword|.kwlist)|
|000054a0| 0a 20 20 20 20 5b 27 65 | 78 63 65 70 74 27 5d 0a |. ['e|xcept'].|
|000054b0| 20 20 20 20 69 00 00 00 | 00 73 11 00 00 00 6e 20 | i...|.s....n |
|000054c0| 6d 75 73 74 20 62 65 20 | 3e 20 30 3a 20 25 72 67 |must be |> 0: %rg|
|000054d0| 00 00 00 00 00 00 00 00 | 67 00 00 00 00 00 00 f0 |........|g.......|
|000054e0| 3f 73 20 00 00 00 63 75 | 74 6f 66 66 20 6d 75 73 |?s ...cu|toff mus|
|000054f0| 74 20 62 65 20 69 6e 20 | 5b 30 2e 30 2c 20 31 2e |t be in |[0.0, 1.|
|00005500| 30 5d 3a 20 25 72 28 0a | 00 00 00 74 0a 00 00 00 |0]: %r(.|...t....|
|00005510| 56 61 6c 75 65 45 72 72 | 6f 72 52 03 00 00 00 52 |ValueErr|orR....R|
|00005520| 19 00 00 00 52 18 00 00 | 00 52 66 00 00 00 52 65 |....R...|.Rf...Re|
|00005530| 00 00 00 52 61 00 00 00 | 52 21 00 00 00 74 05 00 |...Ra...|R!...t..|
|00005540| 00 00 68 65 61 70 71 74 | 08 00 00 00 6e 6c 61 72 |..heapqt|....nlar|
|00005550| 67 65 73 74 28 09 00 00 | 00 74 04 00 00 00 77 6f |gest(...|.t....wo|
|00005560| 72 64 74 0d 00 00 00 70 | 6f 73 73 69 62 69 6c 69 |rdt....p|ossibili|
|00005570| 74 69 65 73 52 26 00 00 | 00 74 06 00 00 00 63 75 |tiesR&..|.t....cu|
|00005580| 74 6f 66 66 74 06 00 00 | 00 72 65 73 75 6c 74 74 |tofft...|.resultt|
|00005590| 01 00 00 00 73 52 45 00 | 00 00 74 04 00 00 00 5f |....sRE.|..t...._|
|000055a0| 5b 31 5d 74 05 00 00 00 | 73 63 6f 72 65 28 00 00 |[1]t....|score(..|
|000055b0| 00 00 28 00 00 00 00 73 | 1d 00 00 00 2f 75 73 72 |..(....s|..../usr|
|000055c0| 2f 6c 69 62 2f 70 79 74 | 68 6f 6e 32 2e 36 2f 64 |/lib/pyt|hon2.6/d|
|000055d0| 69 66 66 6c 69 62 2e 70 | 79 52 00 00 00 00 c0 02 |ifflib.p|yR......|
|000055e0| 00 00 73 20 00 00 00 00 | 1d 0d 01 17 01 1e 01 17 |..s ....|........|
|000055f0| 01 06 01 09 01 0d 01 07 | 00 06 01 0d 01 13 01 13 |........|........|
|00005600| 01 13 01 21 03 12 02 63 | 02 00 00 00 04 00 00 00 |...!...c|........|
|00005610| 03 00 00 00 43 00 00 00 | 73 47 00 00 00 64 01 00 |....C...|sG...d..|
|00005620| 74 00 00 7c 00 00 83 01 | 00 02 7d 02 00 7d 03 00 |t..|....|..}..}..|
|00005630| 78 2d 00 7c 02 00 7c 03 | 00 6a 00 00 6f 1f 00 01 |x-.|..|.|.j..o...|
|00005640| 7c 00 00 7c 02 00 19 7c | 01 00 6a 02 00 6f 0e 00 ||..|...||..j..o..|
|00005650| 01 7c 02 00 64 02 00 37 | 7d 02 00 71 16 00 01 57 |.|..d..7|}..q...W|
|00005660| 7c 02 00 53 28 03 00 00 | 00 73 7d 00 00 00 0a 20 ||..S(...|.s}.... |
|00005670| 20 20 20 52 65 74 75 72 | 6e 20 6e 75 6d 62 65 72 | Retur|n number|
|00005680| 20 6f 66 20 60 63 68 60 | 20 63 68 61 72 61 63 74 | of `ch`| charact|
|00005690| 65 72 73 20 61 74 20 74 | 68 65 20 73 74 61 72 74 |ers at t|he start|
|000056a0| 20 6f 66 20 60 6c 69 6e | 65 60 2e 0a 0a 20 20 20 | of `lin|e`... |
|000056b0| 20 45 78 61 6d 70 6c 65 | 3a 0a 0a 20 20 20 20 3e | Example|:.. >|
|000056c0| 3e 3e 20 5f 63 6f 75 6e | 74 5f 6c 65 61 64 69 6e |>> _coun|t_leadin|
|000056d0| 67 28 27 20 20 20 61 62 | 63 27 2c 20 27 20 27 29 |g(' ab|c', ' ')|
|000056e0| 0a 20 20 20 20 33 0a 20 | 20 20 20 69 00 00 00 00 |. 3. | i....|
|000056f0| 69 01 00 00 00 28 01 00 | 00 00 52 1e 00 00 00 28 |i....(..|..R....(|
|00005700| 04 00 00 00 74 04 00 00 | 00 6c 69 6e 65 74 02 00 |....t...|.linet..|
|00005710| 00 00 63 68 52 28 00 00 | 00 52 26 00 00 00 28 00 |..chR(..|.R&...(.|
|00005720| 00 00 00 28 00 00 00 00 | 73 1d 00 00 00 2f 75 73 |...(....|s..../us|
|00005730| 72 2f 6c 69 62 2f 70 79 | 74 68 6f 6e 32 2e 36 2f |r/lib/py|thon2.6/|
|00005740| 64 69 66 66 6c 69 62 2e | 70 79 74 0e 00 00 00 5f |difflib.|pyt...._|
|00005750| 63 6f 75 6e 74 5f 6c 65 | 61 64 69 6e 67 f0 02 00 |count_le|ading...|
|00005760| 00 73 0a 00 00 00 00 0a | 13 01 03 00 1e 01 0f 01 |.s......|........|
|00005770| 63 00 00 00 00 00 00 00 | 00 03 00 00 00 42 00 00 |c.......|.....B..|
|00005780| 00 73 53 00 00 00 65 00 | 00 5a 01 00 64 00 00 5a |.sS...e.|.Z..d..Z|
|00005790| 02 00 64 08 00 64 08 00 | 64 01 00 84 02 00 5a 04 |..d..d..|d.....Z.|
|000057a0| 00 64 02 00 84 00 00 5a | 05 00 64 03 00 84 00 00 |.d.....Z|..d.....|
|000057b0| 5a 06 00 64 04 00 84 00 | 00 5a 07 00 64 05 00 84 |Z..d....|.Z..d...|
|000057c0| 00 00 5a 08 00 64 06 00 | 84 00 00 5a 09 00 64 07 |..Z..d..|...Z..d.|
|000057d0| 00 84 00 00 5a 0a 00 52 | 53 28 09 00 00 00 73 65 |....Z..R|S(....se|
|000057e0| 0d 00 00 0a 20 20 20 20 | 44 69 66 66 65 72 20 69 |.... |Differ i|
|000057f0| 73 20 61 20 63 6c 61 73 | 73 20 66 6f 72 20 63 6f |s a clas|s for co|
|00005800| 6d 70 61 72 69 6e 67 20 | 73 65 71 75 65 6e 63 65 |mparing |sequence|
|00005810| 73 20 6f 66 20 6c 69 6e | 65 73 20 6f 66 20 74 65 |s of lin|es of te|
|00005820| 78 74 2c 20 61 6e 64 0a | 20 20 20 20 70 72 6f 64 |xt, and.| prod|
|00005830| 75 63 69 6e 67 20 68 75 | 6d 61 6e 2d 72 65 61 64 |ucing hu|man-read|
|00005840| 61 62 6c 65 20 64 69 66 | 66 65 72 65 6e 63 65 73 |able dif|ferences|
|00005850| 20 6f 72 20 64 65 6c 74 | 61 73 2e 20 20 44 69 66 | or delt|as. Dif|
|00005860| 66 65 72 20 75 73 65 73 | 0a 20 20 20 20 53 65 71 |fer uses|. Seq|
|00005870| 75 65 6e 63 65 4d 61 74 | 63 68 65 72 20 62 6f 74 |uenceMat|cher bot|
|00005880| 68 20 74 6f 20 63 6f 6d | 70 61 72 65 20 73 65 71 |h to com|pare seq|
|00005890| 75 65 6e 63 65 73 20 6f | 66 20 6c 69 6e 65 73 2c |uences o|f lines,|
|000058a0| 20 61 6e 64 20 74 6f 20 | 63 6f 6d 70 61 72 65 0a | and to |compare.|
|000058b0| 20 20 20 20 73 65 71 75 | 65 6e 63 65 73 20 6f 66 | sequ|ences of|
|000058c0| 20 63 68 61 72 61 63 74 | 65 72 73 20 77 69 74 68 | charact|ers with|
|000058d0| 69 6e 20 73 69 6d 69 6c | 61 72 20 28 6e 65 61 72 |in simil|ar (near|
|000058e0| 2d 6d 61 74 63 68 69 6e | 67 29 20 6c 69 6e 65 73 |-matchin|g) lines|
|000058f0| 2e 0a 0a 20 20 20 20 45 | 61 63 68 20 6c 69 6e 65 |... E|ach line|
|00005900| 20 6f 66 20 61 20 44 69 | 66 66 65 72 20 64 65 6c | of a Di|ffer del|
|00005910| 74 61 20 62 65 67 69 6e | 73 20 77 69 74 68 20 61 |ta begin|s with a|
|00005920| 20 74 77 6f 2d 6c 65 74 | 74 65 72 20 63 6f 64 65 | two-let|ter code|
|00005930| 3a 0a 0a 20 20 20 20 20 | 20 20 20 27 2d 20 27 20 |:.. | '- ' |
|00005940| 20 20 20 6c 69 6e 65 20 | 75 6e 69 71 75 65 20 74 | line |unique t|
|00005950| 6f 20 73 65 71 75 65 6e | 63 65 20 31 0a 20 20 20 |o sequen|ce 1. |
|00005960| 20 20 20 20 20 27 2b 20 | 27 20 20 20 20 6c 69 6e | '+ |' lin|
|00005970| 65 20 75 6e 69 71 75 65 | 20 74 6f 20 73 65 71 75 |e unique| to sequ|
|00005980| 65 6e 63 65 20 32 0a 20 | 20 20 20 20 20 20 20 27 |ence 2. | '|
|00005990| 20 20 27 20 20 20 20 6c | 69 6e 65 20 63 6f 6d 6d | ' l|ine comm|
|000059a0| 6f 6e 20 74 6f 20 62 6f | 74 68 20 73 65 71 75 65 |on to bo|th seque|
|000059b0| 6e 63 65 73 0a 20 20 20 | 20 20 20 20 20 27 3f 20 |nces. | '? |
|000059c0| 27 20 20 20 20 6c 69 6e | 65 20 6e 6f 74 20 70 72 |' lin|e not pr|
|000059d0| 65 73 65 6e 74 20 69 6e | 20 65 69 74 68 65 72 20 |esent in| either |
|000059e0| 69 6e 70 75 74 20 73 65 | 71 75 65 6e 63 65 0a 0a |input se|quence..|
|000059f0| 20 20 20 20 4c 69 6e 65 | 73 20 62 65 67 69 6e 6e | Line|s beginn|
|00005a00| 69 6e 67 20 77 69 74 68 | 20 27 3f 20 27 20 61 74 |ing with| '? ' at|
|00005a10| 74 65 6d 70 74 20 74 6f | 20 67 75 69 64 65 20 74 |tempt to| guide t|
|00005a20| 68 65 20 65 79 65 20 74 | 6f 20 69 6e 74 72 61 6c |he eye t|o intral|
|00005a30| 69 6e 65 0a 20 20 20 20 | 64 69 66 66 65 72 65 6e |ine. |differen|
|00005a40| 63 65 73 2c 20 61 6e 64 | 20 77 65 72 65 20 6e 6f |ces, and| were no|
|00005a50| 74 20 70 72 65 73 65 6e | 74 20 69 6e 20 65 69 74 |t presen|t in eit|
|00005a60| 68 65 72 20 69 6e 70 75 | 74 20 73 65 71 75 65 6e |her inpu|t sequen|
|00005a70| 63 65 2e 20 20 54 68 65 | 73 65 20 6c 69 6e 65 73 |ce. The|se lines|
|00005a80| 0a 20 20 20 20 63 61 6e | 20 62 65 20 63 6f 6e 66 |. can| be conf|
|00005a90| 75 73 69 6e 67 20 69 66 | 20 74 68 65 20 73 65 71 |using if| the seq|
|00005aa0| 75 65 6e 63 65 73 20 63 | 6f 6e 74 61 69 6e 20 74 |uences c|ontain t|
|00005ab0| 61 62 20 63 68 61 72 61 | 63 74 65 72 73 2e 0a 0a |ab chara|cters...|
|00005ac0| 20 20 20 20 4e 6f 74 65 | 20 74 68 61 74 20 44 69 | Note| that Di|
|00005ad0| 66 66 65 72 20 6d 61 6b | 65 73 20 6e 6f 20 63 6c |ffer mak|es no cl|
|00005ae0| 61 69 6d 20 74 6f 20 70 | 72 6f 64 75 63 65 20 61 |aim to p|roduce a|
|00005af0| 20 2a 6d 69 6e 69 6d 61 | 6c 2a 20 64 69 66 66 2e | *minima|l* diff.|
|00005b00| 20 20 54 6f 20 74 68 65 | 0a 20 20 20 20 63 6f 6e | To the|. con|
|00005b10| 74 72 61 72 79 2c 20 6d | 69 6e 69 6d 61 6c 20 64 |trary, m|inimal d|
|00005b20| 69 66 66 73 20 61 72 65 | 20 6f 66 74 65 6e 20 63 |iffs are| often c|
|00005b30| 6f 75 6e 74 65 72 2d 69 | 6e 74 75 69 74 69 76 65 |ounter-i|ntuitive|
|00005b40| 2c 20 62 65 63 61 75 73 | 65 20 74 68 65 79 20 73 |, becaus|e they s|
|00005b50| 79 6e 63 68 0a 20 20 20 | 20 75 70 20 61 6e 79 77 |ynch. | up anyw|
|00005b60| 68 65 72 65 20 70 6f 73 | 73 69 62 6c 65 2c 20 73 |here pos|sible, s|
|00005b70| 6f 6d 65 74 69 6d 65 73 | 20 61 63 63 69 64 65 6e |ometimes| acciden|
|00005b80| 74 61 6c 20 6d 61 74 63 | 68 65 73 20 31 30 30 20 |tal matc|hes 100 |
|00005b90| 70 61 67 65 73 20 61 70 | 61 72 74 2e 0a 20 20 20 |pages ap|art.. |
|00005ba0| 20 52 65 73 74 72 69 63 | 74 69 6e 67 20 73 79 6e | Restric|ting syn|
|00005bb0| 63 68 20 70 6f 69 6e 74 | 73 20 74 6f 20 63 6f 6e |ch point|s to con|
|00005bc0| 74 69 67 75 6f 75 73 20 | 6d 61 74 63 68 65 73 20 |tiguous |matches |
|00005bd0| 70 72 65 73 65 72 76 65 | 73 20 73 6f 6d 65 20 6e |preserve|s some n|
|00005be0| 6f 74 69 6f 6e 20 6f 66 | 0a 20 20 20 20 6c 6f 63 |otion of|. loc|
|00005bf0| 61 6c 69 74 79 2c 20 61 | 74 20 74 68 65 20 6f 63 |ality, a|t the oc|
|00005c00| 63 61 73 69 6f 6e 61 6c | 20 63 6f 73 74 20 6f 66 |casional| cost of|
|00005c10| 20 70 72 6f 64 75 63 69 | 6e 67 20 61 20 6c 6f 6e | produci|ng a lon|
|00005c20| 67 65 72 20 64 69 66 66 | 2e 0a 0a 20 20 20 20 45 |ger diff|... E|
|00005c30| 78 61 6d 70 6c 65 3a 20 | 43 6f 6d 70 61 72 69 6e |xample: |Comparin|
|00005c40| 67 20 74 77 6f 20 74 65 | 78 74 73 2e 0a 0a 20 20 |g two te|xts... |
|00005c50| 20 20 46 69 72 73 74 20 | 77 65 20 73 65 74 20 75 | First |we set u|
|00005c60| 70 20 74 68 65 20 74 65 | 78 74 73 2c 20 73 65 71 |p the te|xts, seq|
|00005c70| 75 65 6e 63 65 73 20 6f | 66 20 69 6e 64 69 76 69 |uences o|f indivi|
|00005c80| 64 75 61 6c 20 73 69 6e | 67 6c 65 2d 6c 69 6e 65 |dual sin|gle-line|
|00005c90| 20 73 74 72 69 6e 67 73 | 0a 20 20 20 20 65 6e 64 | strings|. end|
|00005ca0| 69 6e 67 20 77 69 74 68 | 20 6e 65 77 6c 69 6e 65 |ing with| newline|
|00005cb0| 73 20 28 73 75 63 68 20 | 73 65 71 75 65 6e 63 65 |s (such |sequence|
|00005cc0| 73 20 63 61 6e 20 61 6c | 73 6f 20 62 65 20 6f 62 |s can al|so be ob|
|00005cd0| 74 61 69 6e 65 64 20 66 | 72 6f 6d 20 74 68 65 0a |tained f|rom the.|
|00005ce0| 20 20 20 20 60 72 65 61 | 64 6c 69 6e 65 73 28 29 | `rea|dlines()|
|00005cf0| 60 20 6d 65 74 68 6f 64 | 20 6f 66 20 66 69 6c 65 |` method| of file|
|00005d00| 2d 6c 69 6b 65 20 6f 62 | 6a 65 63 74 73 29 3a 0a |-like ob|jects):.|
|00005d10| 0a 20 20 20 20 3e 3e 3e | 20 74 65 78 74 31 20 3d |. >>>| text1 =|
|00005d20| 20 27 27 27 20 20 31 2e | 20 42 65 61 75 74 69 66 | ''' 1.| Beautif|
|00005d30| 75 6c 20 69 73 20 62 65 | 74 74 65 72 20 74 68 61 |ul is be|tter tha|
|00005d40| 6e 20 75 67 6c 79 2e 0a | 20 20 20 20 2e 2e 2e 20 |n ugly..| ... |
|00005d50| 20 20 32 2e 20 45 78 70 | 6c 69 63 69 74 20 69 73 | 2. Exp|licit is|
|00005d60| 20 62 65 74 74 65 72 20 | 74 68 61 6e 20 69 6d 70 | better |than imp|
|00005d70| 6c 69 63 69 74 2e 0a 20 | 20 20 20 2e 2e 2e 20 20 |licit.. | ... |
|00005d80| 20 33 2e 20 53 69 6d 70 | 6c 65 20 69 73 20 62 65 | 3. Simp|le is be|
|00005d90| 74 74 65 72 20 74 68 61 | 6e 20 63 6f 6d 70 6c 65 |tter tha|n comple|
|00005da0| 78 2e 0a 20 20 20 20 2e | 2e 2e 20 20 20 34 2e 20 |x.. .|.. 4. |
|00005db0| 43 6f 6d 70 6c 65 78 20 | 69 73 20 62 65 74 74 65 |Complex |is bette|
|00005dc0| 72 20 74 68 61 6e 20 63 | 6f 6d 70 6c 69 63 61 74 |r than c|omplicat|
|00005dd0| 65 64 2e 0a 20 20 20 20 | 2e 2e 2e 20 27 27 27 2e |ed.. |... '''.|
|00005de0| 73 70 6c 69 74 6c 69 6e | 65 73 28 31 29 0a 20 20 |splitlin|es(1). |
|00005df0| 20 20 3e 3e 3e 20 6c 65 | 6e 28 74 65 78 74 31 29 | >>> le|n(text1)|
|00005e00| 0a 20 20 20 20 34 0a 20 | 20 20 20 3e 3e 3e 20 74 |. 4. | >>> t|
|00005e10| 65 78 74 31 5b 30 5d 5b | 2d 31 5d 0a 20 20 20 20 |ext1[0][|-1]. |
|00005e20| 27 5c 6e 27 0a 20 20 20 | 20 3e 3e 3e 20 74 65 78 |'\n'. | >>> tex|
|00005e30| 74 32 20 3d 20 27 27 27 | 20 20 31 2e 20 42 65 61 |t2 = '''| 1. Bea|
|00005e40| 75 74 69 66 75 6c 20 69 | 73 20 62 65 74 74 65 72 |utiful i|s better|
|00005e50| 20 74 68 61 6e 20 75 67 | 6c 79 2e 0a 20 20 20 20 | than ug|ly.. |
|00005e60| 2e 2e 2e 20 20 20 33 2e | 20 20 20 53 69 6d 70 6c |... 3.| Simpl|
|00005e70| 65 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |e is bet|ter than|
|00005e80| 20 63 6f 6d 70 6c 65 78 | 2e 0a 20 20 20 20 2e 2e | complex|.. ..|
|00005e90| 2e 20 20 20 34 2e 20 43 | 6f 6d 70 6c 69 63 61 74 |. 4. C|omplicat|
|00005ea0| 65 64 20 69 73 20 62 65 | 74 74 65 72 20 74 68 61 |ed is be|tter tha|
|00005eb0| 6e 20 63 6f 6d 70 6c 65 | 78 2e 0a 20 20 20 20 2e |n comple|x.. .|
|00005ec0| 2e 2e 20 20 20 35 2e 20 | 46 6c 61 74 20 69 73 20 |.. 5. |Flat is |
|00005ed0| 62 65 74 74 65 72 20 74 | 68 61 6e 20 6e 65 73 74 |better t|han nest|
|00005ee0| 65 64 2e 0a 20 20 20 20 | 2e 2e 2e 20 27 27 27 2e |ed.. |... '''.|
|00005ef0| 73 70 6c 69 74 6c 69 6e | 65 73 28 31 29 0a 0a 20 |splitlin|es(1).. |
|00005f00| 20 20 20 4e 65 78 74 20 | 77 65 20 69 6e 73 74 61 | Next |we insta|
|00005f10| 6e 74 69 61 74 65 20 61 | 20 44 69 66 66 65 72 20 |ntiate a| Differ |
|00005f20| 6f 62 6a 65 63 74 3a 0a | 0a 20 20 20 20 3e 3e 3e |object:.|. >>>|
|00005f30| 20 64 20 3d 20 44 69 66 | 66 65 72 28 29 0a 0a 20 | d = Dif|fer().. |
|00005f40| 20 20 20 4e 6f 74 65 20 | 74 68 61 74 20 77 68 65 | Note |that whe|
|00005f50| 6e 20 69 6e 73 74 61 6e | 74 69 61 74 69 6e 67 20 |n instan|tiating |
|00005f60| 61 20 44 69 66 66 65 72 | 20 6f 62 6a 65 63 74 20 |a Differ| object |
|00005f70| 77 65 20 6d 61 79 20 70 | 61 73 73 20 66 75 6e 63 |we may p|ass func|
|00005f80| 74 69 6f 6e 73 20 74 6f | 0a 20 20 20 20 66 69 6c |tions to|. fil|
|00005f90| 74 65 72 20 6f 75 74 20 | 6c 69 6e 65 20 61 6e 64 |ter out |line and|
|00005fa0| 20 63 68 61 72 61 63 74 | 65 72 20 27 6a 75 6e 6b | charact|er 'junk|
|00005fb0| 27 2e 20 20 53 65 65 20 | 44 69 66 66 65 72 2e 5f |'. See |Differ._|
|00005fc0| 5f 69 6e 69 74 5f 5f 20 | 66 6f 72 20 64 65 74 61 |_init__ |for deta|
|00005fd0| 69 6c 73 2e 0a 0a 20 20 | 20 20 46 69 6e 61 6c 6c |ils... | Finall|
|00005fe0| 79 2c 20 77 65 20 63 6f | 6d 70 61 72 65 20 74 68 |y, we co|mpare th|
|00005ff0| 65 20 74 77 6f 3a 0a 0a | 20 20 20 20 3e 3e 3e 20 |e two:..| >>> |
|00006000| 72 65 73 75 6c 74 20 3d | 20 6c 69 73 74 28 64 2e |result =| list(d.|
|00006010| 63 6f 6d 70 61 72 65 28 | 74 65 78 74 31 2c 20 74 |compare(|text1, t|
|00006020| 65 78 74 32 29 29 0a 0a | 20 20 20 20 27 72 65 73 |ext2))..| 'res|
|00006030| 75 6c 74 27 20 69 73 20 | 61 20 6c 69 73 74 20 6f |ult' is |a list o|
|00006040| 66 20 73 74 72 69 6e 67 | 73 2c 20 73 6f 20 6c 65 |f string|s, so le|
|00006050| 74 27 73 20 70 72 65 74 | 74 79 2d 70 72 69 6e 74 |t's pret|ty-print|
|00006060| 20 69 74 3a 0a 0a 20 20 | 20 20 3e 3e 3e 20 66 72 | it:.. | >>> fr|
|00006070| 6f 6d 20 70 70 72 69 6e | 74 20 69 6d 70 6f 72 74 |om pprin|t import|
|00006080| 20 70 70 72 69 6e 74 20 | 61 73 20 5f 70 70 72 69 | pprint |as _ppri|
|00006090| 6e 74 0a 20 20 20 20 3e | 3e 3e 20 5f 70 70 72 69 |nt. >|>> _ppri|
|000060a0| 6e 74 28 72 65 73 75 6c | 74 29 0a 20 20 20 20 5b |nt(resul|t). [|
|000060b0| 27 20 20 20 20 31 2e 20 | 42 65 61 75 74 69 66 75 |' 1. |Beautifu|
|000060c0| 6c 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |l is bet|ter than|
|000060d0| 20 75 67 6c 79 2e 5c 6e | 27 2c 0a 20 20 20 20 20 | ugly.\n|',. |
|000060e0| 27 2d 20 20 20 32 2e 20 | 45 78 70 6c 69 63 69 74 |'- 2. |Explicit|
|000060f0| 20 69 73 20 62 65 74 74 | 65 72 20 74 68 61 6e 20 | is bett|er than |
|00006100| 69 6d 70 6c 69 63 69 74 | 2e 5c 6e 27 2c 0a 20 20 |implicit|.\n',. |
|00006110| 20 20 20 27 2d 20 20 20 | 33 2e 20 53 69 6d 70 6c | '- |3. Simpl|
|00006120| 65 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |e is bet|ter than|
|00006130| 20 63 6f 6d 70 6c 65 78 | 2e 5c 6e 27 2c 0a 20 20 | complex|.\n',. |
|00006140| 20 20 20 27 2b 20 20 20 | 33 2e 20 20 20 53 69 6d | '+ |3. Sim|
|00006150| 70 6c 65 20 69 73 20 62 | 65 74 74 65 72 20 74 68 |ple is b|etter th|
|00006160| 61 6e 20 63 6f 6d 70 6c | 65 78 2e 5c 6e 27 2c 0a |an compl|ex.\n',.|
|00006170| 20 20 20 20 20 27 3f 20 | 20 20 20 20 2b 2b 5c 6e | '? | ++\n|
|00006180| 27 2c 0a 20 20 20 20 20 | 27 2d 20 20 20 34 2e 20 |',. |'- 4. |
|00006190| 43 6f 6d 70 6c 65 78 20 | 69 73 20 62 65 74 74 65 |Complex |is bette|
|000061a0| 72 20 74 68 61 6e 20 63 | 6f 6d 70 6c 69 63 61 74 |r than c|omplicat|
|000061b0| 65 64 2e 5c 6e 27 2c 0a | 20 20 20 20 20 27 3f 20 |ed.\n',.| '? |
|000061c0| 20 20 20 20 20 20 20 20 | 20 20 20 5e 20 20 20 20 | | ^ |
|000061d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000061e0| 20 2d 2d 2d 2d 20 5e 5c | 6e 27 2c 0a 20 20 20 20 | ---- ^\|n',. |
|000061f0| 20 27 2b 20 20 20 34 2e | 20 43 6f 6d 70 6c 69 63 | '+ 4.| Complic|
|00006200| 61 74 65 64 20 69 73 20 | 62 65 74 74 65 72 20 74 |ated is |better t|
|00006210| 68 61 6e 20 63 6f 6d 70 | 6c 65 78 2e 5c 6e 27 2c |han comp|lex.\n',|
|00006220| 0a 20 20 20 20 20 27 3f | 20 20 20 20 20 20 20 20 |. '?| |
|00006230| 20 20 20 2b 2b 2b 2b 20 | 5e 20 20 20 20 20 20 20 | ++++ |^ |
|00006240| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 5e | | ^|
|00006250| 5c 6e 27 2c 0a 20 20 20 | 20 20 27 2b 20 20 20 35 |\n',. | '+ 5|
|00006260| 2e 20 46 6c 61 74 20 69 | 73 20 62 65 74 74 65 72 |. Flat i|s better|
|00006270| 20 74 68 61 6e 20 6e 65 | 73 74 65 64 2e 5c 6e 27 | than ne|sted.\n'|
|00006280| 5d 0a 0a 20 20 20 20 41 | 73 20 61 20 73 69 6e 67 |].. A|s a sing|
|00006290| 6c 65 20 6d 75 6c 74 69 | 2d 6c 69 6e 65 20 73 74 |le multi|-line st|
|000062a0| 72 69 6e 67 20 69 74 20 | 6c 6f 6f 6b 73 20 6c 69 |ring it |looks li|
|000062b0| 6b 65 20 74 68 69 73 3a | 0a 0a 20 20 20 20 3e 3e |ke this:|.. >>|
|000062c0| 3e 20 70 72 69 6e 74 20 | 27 27 2e 6a 6f 69 6e 28 |> print |''.join(|
|000062d0| 72 65 73 75 6c 74 29 2c | 0a 20 20 20 20 20 20 20 |result),|. |
|000062e0| 20 31 2e 20 42 65 61 75 | 74 69 66 75 6c 20 69 73 | 1. Beau|tiful is|
|000062f0| 20 62 65 74 74 65 72 20 | 74 68 61 6e 20 75 67 6c | better |than ugl|
|00006300| 79 2e 0a 20 20 20 20 2d | 20 20 20 32 2e 20 45 78 |y.. -| 2. Ex|
|00006310| 70 6c 69 63 69 74 20 69 | 73 20 62 65 74 74 65 72 |plicit i|s better|
|00006320| 20 74 68 61 6e 20 69 6d | 70 6c 69 63 69 74 2e 0a | than im|plicit..|
|00006330| 20 20 20 20 2d 20 20 20 | 33 2e 20 53 69 6d 70 6c | - |3. Simpl|
|00006340| 65 20 69 73 20 62 65 74 | 74 65 72 20 74 68 61 6e |e is bet|ter than|
|00006350| 20 63 6f 6d 70 6c 65 78 | 2e 0a 20 20 20 20 2b 20 | complex|.. + |
|00006360| 20 20 33 2e 20 20 20 53 | 69 6d 70 6c 65 20 69 73 | 3. S|imple is|
|00006370| 20 62 65 74 74 65 72 20 | 74 68 61 6e 20 63 6f 6d | better |than com|
|00006380| 70 6c 65 78 2e 0a 20 20 | 20 20 3f 20 20 20 20 20 |plex.. | ? |
|00006390| 2b 2b 0a 20 20 20 20 2d | 20 20 20 34 2e 20 43 6f |++. -| 4. Co|
|000063a0| 6d 70 6c 65 78 20 69 73 | 20 62 65 74 74 65 72 20 |mplex is| better |
|000063b0| 74 68 61 6e 20 63 6f 6d | 70 6c 69 63 61 74 65 64 |than com|plicated|
|000063c0| 2e 0a 20 20 20 20 3f 20 | 20 20 20 20 20 20 20 20 |.. ? | |
|000063d0| 20 20 20 5e 20 20 20 20 | 20 20 20 20 20 20 20 20 | ^ | |
|000063e0| 20 20 20 20 20 20 20 20 | 20 2d 2d 2d 2d 20 5e 0a | | ---- ^.|
|000063f0| 20 20 20 20 2b 20 20 20 | 34 2e 20 43 6f 6d 70 6c | + |4. Compl|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.