Skip to content

Add Maildir.get_flags() to access message flags without opening the file #90890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gildea mannequin opened this issue Feb 12, 2022 · 5 comments
Closed

Add Maildir.get_flags() to access message flags without opening the file #90890

gildea mannequin opened this issue Feb 12, 2022 · 5 comments
Assignees
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement

Comments

@gildea
Copy link
Mannequin

gildea mannequin commented Feb 12, 2022

BPO 46734
Nosy @gildea
PRs
  • gh-90890: Add method mailbox.Maildir.get_flags #31302
  • 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 = None
    closed_at = None
    created_at = <Date 2022-02-12.22:21:50.052>
    labels = ['type-feature', 'library', '3.11']
    title = 'Add Maildir.get_flags() to access message flags without opening the file'
    updated_at = <Date 2022-02-12.22:49:37.459>
    user = 'https://github.com/gildea'

    bugs.python.org fields:

    activity = <Date 2022-02-12.22:49:37.459>
    actor = 'gildea'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2022-02-12.22:21:50.052>
    creator = 'gildea'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46734
    keywords = ['patch']
    message_count = 1.0
    messages = ['413145']
    nosy_count = 1.0
    nosy_names = ['gildea']
    pr_nums = ['31302']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue46734'
    versions = ['Python 3.11']

    Linked PRs

    @gildea
    Copy link
    Mannequin Author

    gildea mannequin commented Feb 12, 2022

    A message's flags are stored in its filename by Maildir, so the flags
    are available without reading the message file itself. The structured
    message file name makes it efficient to scan a large mailbox to select
    only messages that are, for example, not Trashed.

    The mailbox.Maildir interface does not expose these flags, however. The
    only way to access the flags through the mailbox library is to create a
    mailbox.MaildirMessage object, which has a get_flags() method. But
    creating a MaildirMessage requires opening the message file, which is slow.

    I propose adding a parallel get_flags(key) method to mailbox.Maildir,
    so that the flags are available without having to create a
    MaildirMessage object.

    In iterating through a mailbox with thousands of messages, I find that
    this proposed Maildir.get_flags() method is 50 times faster than
    MaildirMessage.get_flags().

    @gildea gildea mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Feb 12, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @gildea
    Copy link
    Contributor

    gildea commented Apr 14, 2023

    Ping. This issue has a patch that needs reviewing

    @gildea
    Copy link
    Contributor

    gildea commented May 25, 2023

    I have updated the patch based on initial review. Please take another look.

    @arhadthedev arhadthedev added 3.13 bugs and security fixes and removed 3.11 only security fixes labels May 25, 2023
    @gildea
    Copy link
    Contributor

    gildea commented Aug 17, 2023

    Ping. This issue has a patch that needs reviewing

    @gpshead gpshead self-assigned this Nov 11, 2023
    gpshead added a commit that referenced this issue Nov 11, 2023
    #103905)
    
    New methods to access mailbox.Maildir message info and flags:
    get_info, set_info, get_flags, set_flags, add_flag, remove_flag.
    
    These methods speed up accessing a message's info and/or flags and are
    useful when it is not necessary to access the message's contents,
    as when iterating over a Maildir to find messages with specific flags.
    
    ---------
    
    * Add more str type checking
    * modernize to f-strings instead of %
    
    Co-authored-by: Gregory P. Smith <greg@krypto.org>
    @gpshead
    Copy link
    Member

    gpshead commented Nov 11, 2023

    Thanks!

    @gpshead gpshead closed this as completed Nov 11, 2023
    serhiy-storchaka pushed a commit that referenced this issue Dec 14, 2023
    When new mailbox.Maildir methods were added for 3.13.0a2, their
    documentation was added at the end of the mailbox.Maildir section
    instead of grouping them with other methods Maildir adds to Mailbox.
    
    This commit moves the new methods' documentation adjacent to
    documentation for existing Maildir-specific methods, so that
    the "special remarks" for common methods remains at the end.
    corona10 pushed a commit to corona10/cpython that referenced this issue Dec 15, 2023
    …H-113071)
    
    When new mailbox.Maildir methods were added for 3.13.0a2, their
    documentation was added at the end of the mailbox.Maildir section
    instead of grouping them with other methods Maildir adds to Mailbox.
    
    This commit moves the new methods' documentation adjacent to
    documentation for existing Maildir-specific methods, so that
    the "special remarks" for common methods remains at the end.
    aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
    …d flags (python#103905)
    
    New methods to access mailbox.Maildir message info and flags:
    get_info, set_info, get_flags, set_flags, add_flag, remove_flag.
    
    These methods speed up accessing a message's info and/or flags and are
    useful when it is not necessary to access the message's contents,
    as when iterating over a Maildir to find messages with specific flags.
    
    ---------
    
    * Add more str type checking
    * modernize to f-strings instead of %
    
    Co-authored-by: Gregory P. Smith <greg@krypto.org>
    aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
    …H-113071)
    
    When new mailbox.Maildir methods were added for 3.13.0a2, their
    documentation was added at the end of the mailbox.Maildir section
    instead of grouping them with other methods Maildir adds to Mailbox.
    
    This commit moves the new methods' documentation adjacent to
    documentation for existing Maildir-specific methods, so that
    the "special remarks" for common methods remains at the end.
    Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
    …d flags (python#103905)
    
    New methods to access mailbox.Maildir message info and flags:
    get_info, set_info, get_flags, set_flags, add_flag, remove_flag.
    
    These methods speed up accessing a message's info and/or flags and are
    useful when it is not necessary to access the message's contents,
    as when iterating over a Maildir to find messages with specific flags.
    
    ---------
    
    * Add more str type checking
    * modernize to f-strings instead of %
    
    Co-authored-by: Gregory P. Smith <greg@krypto.org>
    Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
    …H-113071)
    
    When new mailbox.Maildir methods were added for 3.13.0a2, their
    documentation was added at the end of the mailbox.Maildir section
    instead of grouping them with other methods Maildir adds to Mailbox.
    
    This commit moves the new methods' documentation adjacent to
    documentation for existing Maildir-specific methods, so that
    the "special remarks" for common methods remains at the end.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 bugs and security fixes stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants