Merge branch 'fast-YAML-load' into 'development'

use libyaml-based loader

See merge request damask/DAMASK!570
This commit is contained in:
Daniel Otto de Mentock 2022-05-09 10:58:31 +00:00
commit 7e1d44cd63
1 changed files with 6 additions and 2 deletions

View File

@ -6,6 +6,10 @@ from typing import Union, Dict, Any, Type, TypeVar
import numpy as np
import yaml
try:
from yaml import CSafeLoader as SafeLoader
except ImportError:
from yaml import SafeLoader # type: ignore
from ._typehints import FileHandle
from . import Rotation
@ -53,7 +57,7 @@ class Config(dict):
**kwargs):
"""Initialize from YAML, dict, or key=value pairs."""
if isinstance(yml,str):
kwargs.update(yaml.safe_load(yml))
kwargs.update(yaml.load(yml, Loader=SafeLoader))
elif isinstance(yml,dict):
kwargs.update(yml)
@ -144,7 +148,7 @@ class Config(dict):
Configuration from file.
"""
return cls(yaml.safe_load(util.open_text(fname)))
return cls(yaml.load(util.open_text(fname), Loader=SafeLoader))
def save(self,
fname: FileHandle,