News for hackers. Stuff that matters.
Re:Show HN: Refurb – A tool for refurbishing and modernizing... by tomn on Wednesday September 28, 2022 @10:29AM (#33008379)
If you look at the disassembly, there's no difference in python 3 (I only tested 3.7+), so it's a matter of style.

There used to be a difference in python2 -- the list option would turn into n LOAD_CONSTs and a BUILD_LIST, whereas the tuple option would just emit one LOAD_CONST.

    import dis
    
    def with_tuple():
        for i in (1,2,3):
            print(i)
    
    def with_list():
        for i in [1,2,3]:
            print(i)
    
    print("with_tuple")
    dis.dis(with_tuple)
    print("with_list")
    dis.dis(with_list)
edit: looks like this changed in python 3.6: https://python.godbolt.org/z/rEfY9GT9W

There are no comments on this comment yet.