vyper icon indicating copy to clipboard operation
vyper copied to clipboard

VIP: support pythonic slicing

Open charles-cooper opened this issue 2 years ago • 4 comments

Simple Summary

Allow xs[start:end] instead of slice(xs, start, len)

Motivation

It's more pythonic, less friction for new users.

Backwards Compatibility

We might want to deprecate slice.

Copyright

Copyright and related rights waived via CC0

charles-cooper avatar Mar 14 '22 21:03 charles-cooper

  1. would xs[start:end:step] also work?
  2. What are the restrictions on start, end and step in terms of their value? (constants, immutables, vars, etc.)

fubuloubu avatar Mar 14 '22 21:03 fubuloubu

I think we should disallow step for now

charles-cooper avatar Mar 14 '22 21:03 charles-cooper

the start and end args could have basically the same restrictions as slice, but maybe also allow negative end (so xs[start:-1] would be equivalent to slice(xs, start, len(xs) - start - 1)

charles-cooper avatar Mar 14 '22 21:03 charles-cooper

👋 . Good first issue.

tfire avatar Jul 15 '22 12:07 tfire