opshin
opshin copied to clipboard
Implement Fractions/Rationals
Is your feature request related to a problem? Please describe. A lot of sophisticated applications require fractions. This is not native to UPLC and hence not easy to represent in python
Describe the solution you'd like A sample implementation of fractionals similar to the Plutus implementation would be good and simple to use
Optimally, this uses UPLC primitives and is thus fast and efficient.
For the user this should be importable as from fractions import Fraction
or something in this direction
https://docs.python.org/3/library/fractions.html
Describe alternatives you've considered One could also write a prelude-like implementation of fractions that uses a PlutusData or Tuple Object to represent fractions instead. Since we could exploit the native Pair structure of UPLC though it might make sense to use a native UPLC implementation instead.
Additional context https://github.com/input-output-hk/plutus/blob/master/plutus-tx/src/PlutusTx/Ratio.hs https://github.com/Plutonomicon/pluto/blob/main/examples/field-of-rationals.pluto
The current workaround is #108