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

Augmented Assignment, the Python Way (huge) #32503

Closed
Yhg1s opened this issue Jul 1, 2000 · 10 comments
Closed

Augmented Assignment, the Python Way (huge) #32503

Yhg1s opened this issue Jul 1, 2000 · 10 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@Yhg1s
Copy link
Member

Yhg1s commented Jul 1, 2000

BPO 400699
Nosy @gvanrossum, @Yhg1s
Files
  • None: None
  • 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/Yhg1s'
    closed_at = <Date 2000-08-24.20:12:16.000>
    created_at = <Date 2000-07-01.00:42:41.000>
    labels = ['interpreter-core']
    title = 'Augmented Assignment, the Python Way (huge)'
    updated_at = <Date 2000-08-24.20:12:16.000>
    user = 'https://github.com/Yhg1s'

    bugs.python.org fields:

    activity = <Date 2000-08-24.20:12:16.000>
    actor = 'twouters'
    assignee = 'twouters'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2000-07-01.00:42:41.000>
    creator = 'twouters'
    dependencies = []
    files = ['2509']
    hgrepos = []
    issue_num = 400699
    keywords = ['patch']
    message_count = 10.0
    messages = ['32981', '32982', '32983', '32984', '32985', '32986', '32987', '32988', '32989', '32990']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'jhylton', 'twouters']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue400699'
    versions = []

    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Jul 1, 2000

    No description provided.

    @Yhg1s Yhg1s closed this as completed Jul 1, 2000
    @Yhg1s Yhg1s self-assigned this Jul 1, 2000
    @Yhg1s Yhg1s added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 1, 2000
    @Yhg1s Yhg1s closed this as completed Jul 1, 2000
    @Yhg1s Yhg1s self-assigned this Jul 1, 2000
    @Yhg1s Yhg1s added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 1, 2000
    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Jul 1, 2000

    This patch adds augmented assignment (+=, **=, etc) to Python, in a manner which seems consistent with Guido and Tim's wishes (for as far as I know them.)

    Guido has already stated this patch will not make it to Python 2.0, so the first to read this should probably set the state to 'postponed'. I'll try and keep this patch up to date none the less, for peer (or rather parent ;) reviewal.

    The patch adds everything in one smack: Syntax, a new type of bytecode (2-argument), 9 new bytecodes, 13 new API calls, 11 new PyNumber_Methods members, 2 new PySequence_Methods members, and support for the new functionality in builtin types and supplied Python classes. Oh, and a test suite.

    None the less, it isn't that intrusive a patch, and the simplicity of the implementation still boggles me. For more information, see http://www.xs4all.nl/~thomas/python/
    Comments greatly appreciated! Contact me on thomas@xs4all.net (I'm not on python-dev)

    @gvanrossum
    Copy link
    Member

    Cool! We'll look at this after 2.0 is released...

    @jhylton
    Copy link
    Mannequin

    jhylton mannequin commented Jul 13, 2000

    This patch needs to be postponed until the PEP is written.

    @gvanrossum
    Copy link
    Member

    Not ready to be checked in, but Thomas is working on it!
    This will be in 2.0 after all...

    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Aug 6, 2000

    New version of the patch, that eliminates the need for 2-argument opcodes and the GETSET_* opcodes. Instead, INPLACE_* opcodes are used, that mirror the BINARY_* opcodes, and two new 'utility' opcodes: ROT_FOUR and DUP_TOPX (duplicates the top <x> items on the stack.)

    The PEP documenting this implementation will follow soon.

    @gvanrossum
    Copy link
    Member

    BDFL pronouncement: please use __iadd__, __imul__ etc.

    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Aug 22, 2000

    Up to date version that incorporates the BDFL-Pronouncement to use __iadd__ rather than __add_ab__. Also made PyNumber_InPlacePower() a three-argument function (since normal Power() is one, and we can't change this functions' prototype later, if we would want to.) The three argument InPlacePower() does the normal batch of coercions, so it's not terribly likely to remain an 'in-place' operation :-S

    I'm working on docs, but on my laptop, not incorporated in this patch. Also, the testcase needs to be expanded a bit, and probably incorporated with the test_class testcase I added last week.

    @gvanrossum
    Copy link
    Member

    Accepted. Please check it in. Then work on the docs.

    Please send us the docs even if you don't get to finish them!!!

    @Yhg1s
    Copy link
    Member Author

    Yhg1s commented Aug 24, 2000

    This patch is being checked in right now. However, the patch as found here is not the same as the one being checked in: Guido suggested a better way to do the PyNumber_InPlace*() API functions, which also removes the biggest remaining issue from the PEP, and the patch going in implements that suggestion.

    @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

    2 participants