Discussion:
- for (i, j) in zip(x, x[1:])) - for i, j in zip(x, x[1:])) Do these 2 lines compile to the same Bytecode?
(too old to reply)
HenHanna
2024-06-16 18:10:43 UTC
Permalink
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?
Lawrence D'Oliveiro
2024-06-16 23:58:15 UTC
Permalink
Post by HenHanna
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>
Loading...