| 76 | |
| 77 | @cython.cclass |
| 78 | class to_decimal_processor_factory: |
| 79 | type_: type |
| 80 | format_: str |
| 81 | |
| 82 | __slots__ = ("type_", "format_") |
| 83 | |
| 84 | def __init__(self, type_: type, scale: int): |
| 85 | self.type_ = type_ |
| 86 | self.format_ = f"%.{scale}f" |
| 87 | |
| 88 | def __call__(self, value: Optional[Any]) -> object: |
| 89 | if value is None: |
| 90 | return None |
| 91 | else: |
| 92 | return self.type_(self.format_ % value) |