Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CDumper whenever possible #1152

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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