Skip to content
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

Mutable object change flag #36596

Closed
rhettinger opened this issue May 13, 2002 · 2 comments
Closed

Mutable object change flag #36596

rhettinger opened this issue May 13, 2002 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@rhettinger
Copy link
Contributor

BPO 555251
Nosy @loewis, @rhettinger
Files
  • cache.dif: Context diff for listobject.c and listobject.h
  • 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 = <Date 2002-10-07.21:32:31.000>
    created_at = <Date 2002-05-13.00:22:27.000>
    labels = ['interpreter-core']
    title = 'Mutable object change flag'
    updated_at = <Date 2002-10-07.21:32:31.000>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2002-10-07.21:32:31.000>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2002-05-13.00:22:27.000>
    creator = 'rhettinger'
    dependencies = []
    files = ['4269']
    hgrepos = []
    issue_num = 555251
    keywords = ['patch']
    message_count = 2.0
    messages = ['40017', '40018']
    nosy_count = 2.0
    nosy_names = ['loewis', 'rhettinger']
    pr_nums = []
    priority = 'low'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue555251'
    versions = ['Python 2.3']

    @rhettinger
    Copy link
    Contributor Author

    This patch is a proof-of-concept for marking state
    changes in mutable objects. It is meant as a simpler,
    faster alternative to a full built-in observer pattern.

    Here's the whole protocol:
    Mutable objects choosing to implement the protocol
    provide a writable attribute, cachevalid, which is
    initialized to zero. Upon any update to the object,
    the attribute is reset to zero. Callers who set the
    attribute to one can later check to see if an update
    has occurred (as indicated by a zero).

    >>> a = list('abcd')
    >>> a.cachevalid
    0
    >>> a.cachevalid=1
    >>> a.cachevalid
    1
    >>> a[2] = 'k'
    >>> a.cachevalid
    0

    The proof-of-concept patch is implemented only for
    lists. A production version would need to include
    dictionaries.

    @rhettinger rhettinger added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 13, 2002
    @rhettinger rhettinger added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 13, 2002
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Oct 7, 2002

    Logged In: YES
    user_id=21627

    Raymond, are you still interested in this approach?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant