[issue2551084] Inefficiency in roundup-admin
Tom Ekberg <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
New submission from Tom Ekberg:
I'm using the roundup admin code to create messages, files and issues. Some of the files are rather large. Looking at the roundup/admin.py code at line 104 a split is done to separate a property name from its value. Here are the few lines that matter.
l = arg.split('=')
if len(l) < 2:
raise UsageError(_('argument "%(arg)s" not propname=value'
)%locals())
key, value = l[0], '='.join(l[1:])
As you can see, a split is done on '=' and then a length check is done. After that, the variables key and value are assigned. The value part does a join on '=' to reconstitute it. A better approach is to use the maxsplit argument for split:
l = arg.split('=', 1)
if len(l) < 2:
raise UsageError(_('argument "%(arg)s" not propname=value'
)%locals())
key, value = l
Here, the arg is split into at most 2 pieces (1 split), the length check is done, and the key and value are assigned.
While this may not be important for small propname/value pairs in roundup-admin, it is important when the value is large, like files. In addition, the code is simpler. If you would like a diff and/or a test case for this, please let me know.
----------
components: Command-line interface
messages: 6909
nosy: rouilj, tekberg
severity: normal
status: new
title: Inefficiency in roundup-admin
type: behavior
versions: devel
_________________________________________________
Roundup tracker <[email protected]>
<https://issues.roundup-tracker.org/issue2551084>
_________________________________________________