Merge branch 'fast-YAML-load' into 'development'
use libyaml-based loader See merge request damask/DAMASK!570
This commit is contained in:
commit
7e1d44cd63
|
@ -6,6 +6,10 @@ from typing import Union, Dict, Any, Type, TypeVar
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import yaml
|
import yaml
|
||||||
|
try:
|
||||||
|
from yaml import CSafeLoader as SafeLoader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import SafeLoader # type: ignore
|
||||||
|
|
||||||
from ._typehints import FileHandle
|
from ._typehints import FileHandle
|
||||||
from . import Rotation
|
from . import Rotation
|
||||||
|
@ -53,7 +57,7 @@ class Config(dict):
|
||||||
**kwargs):
|
**kwargs):
|
||||||
"""Initialize from YAML, dict, or key=value pairs."""
|
"""Initialize from YAML, dict, or key=value pairs."""
|
||||||
if isinstance(yml,str):
|
if isinstance(yml,str):
|
||||||
kwargs.update(yaml.safe_load(yml))
|
kwargs.update(yaml.load(yml, Loader=SafeLoader))
|
||||||
elif isinstance(yml,dict):
|
elif isinstance(yml,dict):
|
||||||
kwargs.update(yml)
|
kwargs.update(yml)
|
||||||
|
|
||||||
|
@ -144,7 +148,7 @@ class Config(dict):
|
||||||
Configuration from file.
|
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,
|
def save(self,
|
||||||
fname: FileHandle,
|
fname: FileHandle,
|
||||||
|
|
Loading…
Reference in New Issue