[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

2015-08-20 Thread Robert Collins
Robert Collins added the comment: So - I'm with Victor and Raymond here. I think modifying difflib to provide external control over the poor-O components would permit many more benefits than just controlling time: you could wrap them in a timer module to get what this patch does, you could

[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

2015-08-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: In general, it isn't good design to incorporate timeout logic in computation logic. What would be better is a general purpose, reusable, decoupled tool: run_with_time_limit(some_computation, some_args, time_limit). Such a tool might be based on separate

[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

2015-08-20 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- nosy: +tim.peters ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24904 ___ ___

[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

2015-08-20 Thread John Taylor
New submission from John Taylor: SequenceMatcher in the difflib module contain ratio() and quick_ratio() methods which can take a long time to run with certain input. One example is two slightly different versions of jquery.min.js. I have written a patch against python-350b4 that adds a

[issue24904] Patch: add timeout to difflib SequenceMatcher ratio() and quick_ratio()

2015-08-20 Thread STINNER Victor
STINNER Victor added the comment: I'm not sure that it's a good idea to add a timeout to such algorithm. It can be very surprising to have a difference result depending on the system load (CPU usage of _other_ applications) and on the CPU performances. If you really want this result, I would