Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PInterval can have more efficient representation for more complicated manipulation #796

Open
SeungheonOh opened this issue Jan 7, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@SeungheonOh
Copy link
Collaborator

SeungheonOh commented Jan 7, 2025

PInterval as it is provided by the ledger api is very inefficient for complicated operations on interval. pcontains as it is is well optimized and having intermediary representation will actually do harm on its performance by introducing extra conversion from ledger type to intermediary type. However, if script requires multiple and more complicated operations(like a series of checking interval union, intersection, etc, etc) on interval, it would be cheaper to convert ledger interval into intermediary interval, do multiple operation on converted interval, and convert back to ledger interval.

Below is possible idea for more efficient intermediary interval proposed by @kozross.

data PClosured (a :: S -> Type) (s :: S) = POpen (Term s a) | PClosed (Term s a)

data PIntervalSensible (a :: S -> Type) (s :: S) = 
   = PNever
   | PAlways
   | PStartNoEnd (Term s (PClosure a)) 
   | PEndNoStart (Term s (PClosure a))
   | PIntervalSensible (Term s (PClosure a)) (Term s (PClosure a))

Because this optimization is very specifically targeted to scripts that require complicated interval operations, this issue will only be implemented upon request if any project need this.

@SeungheonOh SeungheonOh added the enhancement New feature or request label Jan 7, 2025
@t4ccer
Copy link
Collaborator

t4ccer commented Jan 17, 2025

If the interval is only used for discrete types like PPosixTime it can be simplified even more by not doing PClosure but + 1 instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants