Open mvpeterson opened 6 months ago
adding types doesn't change the performance
(: List (-> $t Type))
(: Nil (List $t))
(: Cons (-> $t (List $t) (List $t)))
; convert (a b c) to (Cons a (Cons b (Cons c Nil)))
(: makelist (-> Atom (List $t)))
Interesting that Python is six times slower than Rust REPL on this task which is strange.
This issue somewhat relates to one I've just created as well https://github.com/trueagi-io/hyperon-experimental/issues/638
From the code logic perspective nothing is wrong here. Although I recommend adding types as @noskill suggested in https://github.com/trueagi-io/metta-examples/issues/42#issuecomment-2014866684.
It is a performance issue. So I would suggest closing it as a duplicate of https://github.com/trueagi-io/hyperon-experimental/issues/638
@vsbogd is the issue caused by argument of car-atom being evaluated? If so why it gets evaluated? I remember you told me that built-in metta types are not evaluated
@vsbogd is the issue caused by argument of car-atom being evaluated?
It is not evaluated in this context. If you see it is evaluated in log the reason is ==
has type (-> $t $t Bool)
.
What do you think about adding differently typed == operator?
works faster, but not much
(: same (-> Atom Atom Bool))
(= (same $X $Y) False)
(= (same $X $X) True)
(= (makelist $x)
(if (same () $x) Nil (let $_cdr (cdr-atom $x)
(Cons (car-atom $x) (makelist $_cdr)))
)
)
It takes about 1 minute to create a list of 24 elements in minimal Metta. Is there a way to make it work faster?