From 754ba589b7c94a178636c10fe9812350bbbdb445 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Tue, 20 Feb 2001 11:24:35 +0000 Subject: Improve accuracy. In the .tex file, note the new "% BUG:" comments: an extra backslash is getting displayed in the generated HTML. --- Doc/lib/libdifflib.tex | 19 ++++++++++++------- Lib/difflib.py | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Doc/lib/libdifflib.tex b/Doc/lib/libdifflib.tex index 61f6cb5..128552b 100644 --- a/Doc/lib/libdifflib.tex +++ b/Doc/lib/libdifflib.tex @@ -53,8 +53,8 @@ \strong{Timing:} The basic Ratcliff-Obershelp algorithm is cubic time in the worst case and quadratic time in the expected case. \class{SequenceMatcher} is quadratic time for the worst case and has - expected-case behavior dependent on how many elements the sequences - have in common; best case time (no elements in common) is linear. + expected-case behavior dependent in a complicated way on how many + elements the sequences have in common; best case time is linear. \end{classdesc} @@ -68,6 +68,9 @@ \code{None} is equivalent to passing \code{lambda x: 0}, i.e.\ no elements are ignored. For example, pass +% BUG: the HTML generated for this is +% BUG: lambda x: x in " \\t" +% BUG: i.e. it displays two backslashes. \begin{verbatim} lambda x: x in " \\t" \end{verbatim} @@ -138,7 +141,7 @@ of the other sequences. junk happens to be adjacent to an interesting match. Here's the same example as before, but considering blanks to be junk. - That prevents \code{' abcd'} from matching the \code{ abcd} at the + That prevents \code{' abcd'} from matching the \code{' abcd'} at the tail end of the second sequence directly. Instead only the \code{'abcd'} can match, and matches the leftmost \code{'abcd'} in the second sequence: @@ -217,8 +220,8 @@ replace a[3:4] (x) b[2:3] (y) range [0, 1]. Where T is the total number of elements in both sequences, and M is - the number of matches, this is 2,0*M / T. Note that this is \code{1} - if the sequences are identical, and \code{0} if they have nothing in + the number of matches, this is 2.0*M / T. Note that this is \code{1.} + if the sequences are identical, and \code{0.} if they have nothing in common. This is expensive to compute if \method{get_matching_blocks()} or @@ -242,8 +245,10 @@ replace a[3:4] (x) b[2:3] (y) \method{ratio()} or \method{quick_ratio()}. \end{methoddesc} -The three methods that return the ratio of differences to similarities -can give different results due to differing levels of approximation: +The three methods that return the ratio of matching to total characters +can give different results due to differing levels of approximation, +although \method{quick_ratio()} and \method{real_quick_ratio()} are always +at least as large as \method{ratio()}: \begin{verbatim} >>> s = SequenceMatcher(None, "abcd", "bcde") diff --git a/Lib/difflib.py b/Lib/difflib.py index 759d33f..deb7361 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -92,9 +92,9 @@ See also function get_close_matches() in this module, which shows how simple code building on SequenceMatcher can be used to do useful work. Timing: Basic R-O is cubic time worst case and quadratic time expected -case. SequenceMatcher is quadratic time worst case and has expected-case -behavior dependent on how many elements the sequences have in common; best -case time (no elements in common) is linear. +case. SequenceMatcher is quadratic time for the worst case and has +expected-case behavior dependent in a complicated way on how many +elements the sequences have in common; best case time is linear. SequenceMatcher methods: -- cgit v0.12 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/* module.h - definitions for the module
 *
 * Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
 *
 * This file is part of pysqlite.
 *
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 */

#ifndef PYSQLITE_MODULE_H
#define PYSQLITE_MODULE_H
#include "Python.h"

#define PYSQLITE_VERSION "2.6.0"

extern PyObject* pysqlite_Error;
extern PyObject* pysqlite_Warning;
extern PyObject* pysqlite_InterfaceError;
extern PyObject* pysqlite_DatabaseError;
extern PyObject* pysqlite_InternalError;
extern PyObject* pysqlite_OperationalError;
extern PyObject* pysqlite_ProgrammingError;
extern PyObject* pysqlite_IntegrityError;
extern PyObject* pysqlite_DataError;
extern PyObject* pysqlite_NotSupportedError;

extern PyObject* pysqlite_OptimizedUnicode;

/* the functions time.time() and time.sleep() */
extern PyObject* time_time;
extern PyObject* time_sleep;

/* A dictionary, mapping colum types (INTEGER, VARCHAR, etc.) to converter
 * functions, that convert the SQL value to the appropriate Python value.
 * The key is uppercase.
 */
extern PyObject* converters;

extern int _enable_callback_tracebacks;
extern int pysqlite_BaseTypeAdapted;

#define PARSE_DECLTYPES 1
#define PARSE_COLNAMES 2
#endif