简体   繁体   English

保存每个字段的所有配置VS访问configObj

[英]save all config VS access configObj for each field

I have a config file abc.ini with trivial fields 我有一个包含琐碎字段的配置文件abc.ini

[SET_1]
a=1
b=2
c=3

[SET_2]
d=4
e=5

Now, in the script(python) I can do 2 things: 现在,在脚本(python)中,我可以做两件事:

  1. Access the file abc.ini once and save all config in a data structure 一次访问文件abc.ini并将所有配置保存在数据结构中
  2. Access the each field where I need them as configObj[SET_1][a] etc 以configObj [SET_1] [a]等方式访问需要它们的每个字段

Which of these is more efficient and why. 其中哪个更有效,为什么。

A ConfigObj section actually inherits from a Python dict , so both approaches will actually use the same underlying data structure. ConfigObj部分实际上是从python dict继承的,因此这两种方法实际上都将使用相同的基础数据结构。 There will be no difference in performance. 性能不会有差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM