opshin icon indicating copy to clipboard operation
opshin copied to clipboard

Implement python builtin functions

Open nielstron opened this issue 2 years ago • 1 comments

Builtin functions simplify usage of Eopsin to build contracts, and can improve performance at the same time through native implementations.

Below is a list of builtins that python offers and should be supported by Eopsin as well. Striked through functions are not planned.

  • [x] all (8b7ac91f4a9935a9423095d787eaff3c52208114)
  • [x] any (8b7ac91f4a9935a9423095d787eaff3c52208114)
  • [x] abs (2edc63698980fde9e9e2b067d9d19f6db7fbe056)
  • [ ] bin
  • [ ] bool
  • [x] breakpoint (a no-op) (added in 42a75d35422e6132d9d95181b08c3bda2be03b42)
  • [ ] bytearray (synonym for bytes?)
  • [x] bytes (constructor with list of integers)
  • [ ] ~~callable~~
  • [x] chr
  • [ ] classmethod
  • [ ] ~~compile~~
  • [ ] complex (with rationals and integers)
  • [ ] ~~delattr~~
  • [ ] dict
  • [ ] dir
  • [ ] dict
  • [ ] divmod
  • [ ] enumerate
  • [ ] ~~eval~~
  • [ ] ~~exec~~
  • [ ] filter
  • [ ] ~~float~~
  • [ ] format
  • [ ] frozenset
  • [ ] ~~getattr~~
  • [ ] ~~globals~~
  • [ ] ~~hasattr~~
  • [ ] hash
  • [ ] ~~help~~
  • [x] hex
  • [ ] ~~id~~
  • [ ] ~~input~~
  • [ ] int
    • [x] str (base 10)
    • [ ] fraction
    • [x] int
  • [ ] isinstance (to distinguish elements of Union types)
  • [ ] ~~issubclass~~
  • [ ] iter
  • [ ] len
    • [x] bytes
    • [x] list
    • [ ] str
  • [ ] list
  • [ ] ~~locals~~
  • [ ] map
  • [x] max
  • [x] min
  • [ ] next
  • [ ] ~~object~~
  • [x] oct
  • [ ] ~~open~~
  • [ ] ord
  • [x] pow
    • [ ] with negative exponents -> fractions?
    • [ ] with modulo -> for anyone wanting to implement efficient modulo exponentiation in UPLC
  • [x] print
  • [ ] property
  • [x] range
  • [x] reversed
  • [ ] round (for fractions)
  • [ ] set
  • [ ] ~~setattr~~
  • [ ] slice
  • [ ] sorted
  • [ ] staticmethod
  • [x] str
    • [x] int
    • [x] fraction
    • [x] str
    • [x] bytes
    • [x] list
    • [x] tuple
    • [x] data?
  • [x] sum (added in 23bdda58c62f2029c4fa558e19ec348cd7147726)
  • [ ] ~~super~~
  • [ ] tuple
  • [ ] ~~type~~
  • [ ] ~~vars~~
  • [ ] zip
  • [ ] ~~import~~

Reference:

https://docs.python.org/3/library/functions.html

nielstron avatar Feb 06 '23 21:02 nielstron

Since the introduction of the pairtype with #36 we can also implement zip

nielstron avatar Jun 02 '23 22:06 nielstron