Skip to content

Commit

Permalink
Use CDumper whenever possible (#1152)
Browse files Browse the repository at this point in the history
Use CDumper whenever possible0
  • Loading branch information
wouterzwerink committed Jan 17, 2024
1 parent e374b4a commit d888120
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/1152.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The YAML dumper will now use `yaml.CDumper` instead of `yaml.Dumper` whenever possible to speed up dumping
9 changes: 8 additions & 1 deletion omegaconf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
except ImportError: # pragma: no cover
BaseLoader = yaml.SafeLoader

try:
from yaml import CDumper

BaseDumper = CDumper
except ImportError: # pragma: no cover
BaseDumper = yaml.Dumper

NoneType: Type[None] = type(None)

BUILTIN_VALUE_TYPES: Tuple[Type[Any], ...] = (
Expand Down Expand Up @@ -105,7 +112,7 @@ def __repr__(self) -> str:
_DEFAULT_MARKER_: Any = Marker("_DEFAULT_MARKER_")


class OmegaConfDumper(yaml.Dumper): # type: ignore
class OmegaConfDumper(BaseDumper): # type: ignore
str_representer_added = False

@staticmethod
Expand Down

0 comments on commit d888120

Please sign in to comment.