Skip to content

difflib.SequenceMatcher: expose junk sets, deprecate undocumented isb... functions. #54743

Closed

Description

@terryjreedy
BPO 10534
Nosy @birkenfeld, @terryjreedy
Files
  • difflib.10534.diff: Expose junk & popular; doc along with b2j
  • issue10534.2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2010-12-15.20:23:44.035>
    created_at = <Date 2010-11-25.20:20:56.238>
    labels = ['type-feature']
    title = 'difflib.SequenceMatcher: expose junk sets, deprecate undocumented isb... functions.'
    updated_at = <Date 2010-12-15.20:23:44.033>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2010-12-15.20:23:44.033>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2010-12-15.20:23:44.035>
    closer = 'terry.reedy'
    components = []
    creation = <Date 2010-11-25.20:20:56.238>
    creator = 'terry.reedy'
    dependencies = []
    files = ['19915', '19932']
    hgrepos = []
    issue_num = 10534
    keywords = ['patch']
    message_count = 8.0
    messages = ['122400', '123152', '123194', '123280', '123299', '123304', '123317', '124065']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'hodgestar', 'eli.bendersky']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue10534'
    versions = ['Python 3.2']

    Activity

    1. terryjreedy commented on Nov 25, 2010

      @terryjreedy
      MemberAuthor

      Expose and document the junk and popular sets as attributes of the SequenceMatcher object.

      self.junk = junk
      self.popular = popular

      Deprecate the then unneeded and undocumented isbjunk and isbpopular functions, currently defined as
      self.isbjunk = junk.__contains__
      self.isbpopular = popular.__contains__
      (and slightly modify the matcher function that localizes and uses one of the above).

      Question, (how) do we document deprecation/removal of undocumented function?

      In discussions that included Tim Peters, the idea of exposing the tuning parameters of the heuristic was discussed. Now that the heuristic can be turned off, I think this is YAGNI until someone specifically requests it.

    2. self-assigned this
      on Nov 25, 2010
    3. added
      type-feature
      on Nov 25, 2010
    4. terryjreedy commented on Dec 3, 2010

      @terryjreedy
      MemberAuthor

      Here is a pretty minimal patch to expose bjunk and bpopular as attributes and document them along with b2j, which is already exposed but not documented.

      I suppose the proposed paragraph could be formatted as a list, perhaps after
      ":class:`SequenceMatcher` objects have the following methods:"
      with 'methods' expanded to 'attributes and methods'. But I do not know how to do that and personally prefer what I wrote.

      However, Georg, I am adding you as nosy so you can comment on the doc addition *before* I commit this tomorrow, to get it in the beta.

      Still to do: improve the doctests, including those added as part of bpo-2986, to use the exposed sets (they are already implicitly tested by the existing tests); deprecate the two obsolete function attributes, as discussed on pydev.

      The docstrings and code comments might stand revision, and there is an XXX todo in the doc yet.

    5. birkenfeld commented on Dec 3, 2010

      @birkenfeld
      Member

      Don't worry about doc additions too much; all doc changes can be considered bug fixes.

      In this patch, it appears that two of the three attributes are new? They should get a versionadded.

    6. terryjreedy commented on Dec 3, 2010

      @terryjreedy
      MemberAuthor

      Added version-added and committed. r86983

    7. terryjreedy commented on Dec 3, 2010

      @terryjreedy
      MemberAuthor

      Deprecated isbjunk and isbpopular methods, ran doc and unit tests, and committed as r87000. Still need to add 'gone in 3.3 test' when revise unittests.

    8. terryjreedy commented on Dec 3, 2010

      @terryjreedy
      MemberAuthor

      News entry for both commits: r87001

    9. elibendersky commented on Dec 4, 2010

      elibenderskymannequin
      Mannequin

      Terry,

      Attaching a patch with the following:

      1. Added unittest assertions for bjunk and bpopular data attributes.
      2. Minor markup & formatting fixes in one paragraph of the doc difflib.rst
    10. terryjreedy commented on Dec 15, 2010

      @terryjreedy
      MemberAuthor

      Added tweak to .__chain_b to avoid creating list of b2j.keys and .items be deleting from b2j in separate loop after creating sets. Test with timeit suggests time about same with 1% deletion. r87276

    11. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    type-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions