• - for (i, j) in zip(x, x[1:])) - for i, j in zip(x, x[1:])) Do these 2

    From HenHanna@21:1/5 to All on Sun Jun 16 11:10:43 2024
    def diff1(x):
    return all(abs(i-j) == 1 for (i, j) in zip(x, x[1:]))


    - for (i, j) in zip(x, x[1:]))
    - for i, j in zip(x, x[1:]))

    Do the above 2 lines compile to the same Bytecode?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to HenHanna on Sun Jun 16 23:58:15 2024
    On Sun, 16 Jun 2024 11:10:43 -0700, HenHanna wrote:

    def diff1(x):
    return all(abs(i-j) == 1 for (i, j) in zip(x, x[1:]))


    - for (i, j) in zip(x, x[1:]))
    - for i, j in zip(x, x[1:]))

    Do the above 2 lines compile to the same Bytecode?

    Try it for yourself and see. Tips on how to proceed: <https://gitlab.com/ldo/python_topics_notebooks/-/blob/master/Python%20Language%20Services.ipynb?ref_type=heads>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)