Skip to content

Commit

Permalink
remove all package imports for better perf
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiyuan Chen <[email protected]>
  • Loading branch information
ZhiyuanChen committed Jan 4, 2023
1 parent 1054470 commit 935c1fe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CHANfiG 有着强大的前向兼容能力,能够良好的兼容以往基于yam
如果你此前使用yacs,只需简单将`CfgNode`替换为`Config`便可以享受所有CHANfiG所提供的便利。

```python
from chanfig import Config
from chanfig import Config, Variable


class Model:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ No matter your old config is json or yaml, you could directly read from them.
And if you are using yacs, just replace `CfgNode` with `Config` and enjoy all the additional benefits that CHANfiG provides.

```python
from chanfig import Config
from chanfig import Config, Variable


class Model:
Expand Down Expand Up @@ -87,7 +87,7 @@ if __name__ == '__main__':
config = config.parse()
# config.update('dataset.yaml') # in case you want to merge a yaml
# config.update('dataset.json') # in case you want to merge a json
# note that the value of merge will surpass current values
# note that the value of merge will override current values
config.model.decoder.num_layers = 8
config.freeze()
print(config)
Expand Down
4 changes: 2 additions & 2 deletions chanfig/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from argparse import ArgumentParser
from ast import literal_eval
from collections import OrderedDict as OrderedDict_
Expand All @@ -13,6 +12,7 @@
from json import loads as json_loads
from os import PathLike
from os.path import splitext
from sys import argv
from typing import IO, Any, Callable, Iterable, List, Optional, Sequence, Union
from warnings import warn

Expand Down Expand Up @@ -89,7 +89,7 @@ def parse(
"""

if args is None:
args = sys.argv[1:]
args = argv[1:]
for arg in args:
if arg.startswith("--") and args != "--":
arg = arg.split("=")[0]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ CHANfiG 有着强大的前向兼容能力,能够良好的兼容以往基于yam
现有代码:

```python
from chanfig import Config
from chanfig import Config, Variable


class Model:
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ No matter your old config is json or yaml, you could directly read from them.
And if you are using yacs, just replace `CfgNode` with `Config` and enjoy all the additional benefits that CHANfiG provides.

```python
from chanfig import Config
from chanfig import Config, Variable


class Model:
Expand Down Expand Up @@ -87,7 +87,7 @@ if __name__ == '__main__':
config = config.parse()
# config.update('dataset.yaml') # in case you want to merge a yaml
# config.update('dataset.json') # in case you want to merge a json
# note that the value of merge will surpass current values
# note that the value of merge will override current values
config.model.decoder.num_layers = 8
config.freeze()
print(config)
Expand Down

0 comments on commit 935c1fe

Please sign in to comment.