mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-30 09:00:24 +08:00
Improve utils.decimalize performace [h/t ubmarco]
See: https://github.com/jsvine/pdfplumber/issues/197
This commit is contained in:
@@ -377,6 +377,7 @@ Many thanks to the following users who've contributed ideas, features, and fixes
|
||||
- [Samkit Jain](https://github.com/samkit-jain)
|
||||
- [Francisco Aranda](https://github.com/frascuchon)
|
||||
- [Kwok-kuen Cheung](https://github.com/cheungpat)
|
||||
- [Marco](https://github.com/ubmarco)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
+5
-1
@@ -88,7 +88,7 @@ def decode_psl_list(_list):
|
||||
@cache(maxsize = int(10e4))
|
||||
def _decimalize(v, q = None):
|
||||
# If already a decimal, just return itself
|
||||
if isinstance(v, Decimal):
|
||||
if type(v) == Decimal:
|
||||
return v
|
||||
|
||||
# If tuple/list passed, bulk-convert
|
||||
@@ -110,6 +110,10 @@ def _decimalize(v, q = None):
|
||||
raise ValueError("Cannot convert {0} to Decimal.".format(v))
|
||||
|
||||
def decimalize(v, q = None):
|
||||
# If already a decimal, just return itself
|
||||
if type(v) == Decimal:
|
||||
return v
|
||||
|
||||
# If tuple/list passed, bulk-convert
|
||||
if isinstance(v, (tuple, list)):
|
||||
return type(v)(decimalize(x, q) for x in v)
|
||||
|
||||
Reference in New Issue
Block a user