From ba2062e4ed6d277c9a2dec20c0dbd33158d8428c Mon Sep 17 00:00:00 2001 From: Daniel Otto de Mentock Date: Tue, 6 Dec 2022 20:17:23 +0000 Subject: [PATCH] CSafeDumper is significantly faster and can be subclassed for custom extensions. --- python/damask/_config.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/damask/_config.py b/python/damask/_config.py index f6714cd81..8163da980 100644 --- a/python/damask/_config.py +++ b/python/damask/_config.py @@ -8,8 +8,10 @@ import numpy as np import yaml try: from yaml import CSafeLoader as SafeLoader + from yaml import CSafeDumper as SafeDumper except ImportError: from yaml import SafeLoader # type: ignore + from yaml import SafeDumper # type: ignore from ._typehints import FileHandle from . import Rotation @@ -17,20 +19,20 @@ from . import util MyType = TypeVar('MyType', bound='Config') -class NiceDumper(yaml.SafeDumper): +class NiceDumper(SafeDumper): """Make YAML readable for humans.""" def write_line_break(self, data: Optional[str] = None): - super().write_line_break(data) + super().write_line_break(data) # type: ignore - if len(self.indents) == 1: - super().write_line_break() + if len(self.indents) == 1: # type: ignore + super().write_line_break() # type: ignore def increase_indent(self, flow: bool = False, indentless: bool = False): - return super().increase_indent(flow, False) + return super().increase_indent(flow, False) # type: ignore def represent_data(self, data: Any):