Skip to content

Commit

Permalink
refactor: use hugr lowering for ipow
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Feb 17, 2025
1 parent 01903d3 commit 617a4cb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions guppylang/std/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ def __or__(self: int, other: int) -> int: ...
@guppy.custom(NoopCompiler())
def __pos__(self: int) -> int: ...

# TODO use hugr int op "ipow"
# once lowering available
@guppy
@no_type_check
def __pow__(self: int, exponent: int) -> int:
Expand All @@ -365,10 +363,10 @@ def __pow__(self: int, exponent: int) -> int:
"Negative exponent not supported in"
"__pow__ with int type base. Try casting the base to float."
)
res = 1
for _ in range(exponent):
res *= self
return res
return self.__pow_impl(exponent)

@guppy.hugr_op(int_op("ipow"))
def __pow_impl(self: int, exponent: int) -> int: ...

@guppy.custom(checker=ReversingChecker())
def __radd__(self: int, other: int) -> int: ...
Expand Down

0 comments on commit 617a4cb

Please sign in to comment.