Skip to content

Commit

Permalink
micro-optimize the int_to_Money function
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Oct 22, 2018
1 parent 62590d5 commit 509df03
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions liberapay/payin/stripe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from decimal import Decimal

import stripe
import stripe.error

Expand All @@ -17,8 +19,8 @@
def int_to_Money(amount, currency):
currency = currency.upper()
if currency in ZERO_DECIMAL_CURRENCIES:
return Money(amount, currency)
return Money(amount, currency) / 100
return Money(Decimal(amount), currency)
return Money(Decimal(amount) / 100, currency)


def Money_to_int(m):
Expand Down

0 comments on commit 509df03

Please sign in to comment.