What is the fastest way to pass a short list of command line options?
I started with just a list, then thought about using a numpy array, because as I understand it then the items in the array are all pre-typed and stored more efficiently in memory.
Is it maybe worth Cythonizing the function? Is it even worth using the numpy array, or am I most-likely prematurely optimizing?
The arg string/list looks like this:
ARG_STRING = 'cdehinu:'
ARG_LIST = ['credentials',
'delete_user',
'email',
'help',
'ip',
'notifications',
'user_load=']
And a minimal example of the parsing function looks like this:
def arg_parse(self, opts):
for opt, arg in np.array(opts): # here I have added the numpy conversion
if opt in {'-i', '--ip'}:
do.something()
elif opt in {-h, '--help}:
do.something_else()
...
I know at the end of the day, it's all rather unnecessary, and my feeling is that converting it to an array is going to take as much if not more time than it saves in this small list, but in the interests of best (and/or fastest) practices, I'd love to hear some more experienced people's thoughts on the matter, or other ideas how this process could be optimized.
Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…