> On Dec. 23, 2014, 9:18 a.m., Matt Jordan wrote: > > /branches/12/contrib/scripts/sip_to_pjsip/astconfigparser.py, lines 334-335 > > <https://reviewboard.asterisk.org/r/4280/diff/2/?file=69851#file69851line334> > > > > This could be written as: > > > > res.extend([inc.get_sections(key, attr, searched) for inc in > > self._includes]) > > > > Two reasons for this change: > > (1) generally, list comprehensions are a bit faster than for loops that > > build a list. > > (2) using an explicit extend with a list comprehension informs the > > reader of the intent of the code over the += operator. (Note: the > > difference between '+' and '+=' on a list caught me by surprise the first > > time. I'm less a fan of using operators on a list than using explicit > > methods.)
While I agree with the reasons for your change, the realization of your suggestion ends up being: res.extend(list(itertools.chain(*[self._includes[i].get_sections(key, attr, searched) for i in self._includes]))) Due to self._includes being a dict and the need to flatten the list before adding to res. I'm concerned that this is a loss in readability, even though it is certainly faster. - Scott ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviewboard.asterisk.org/r/4280/#review14033 ----------------------------------------------------------- On Dec. 19, 2014, 7:52 a.m., Scott Griepentrog wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviewboard.asterisk.org/r/4280/ > ----------------------------------------------------------- > > (Updated Dec. 19, 2014, 7:52 a.m.) > > > Review request for Asterisk Developers. > > > Bugs: ASTERISK-24474 > https://issues.asterisk.org/jira/browse/ASTERISK-24474 > > > Repository: Asterisk > > > Description > ------- > > General improvements to reliability of conversion utility: > > 1) track default section of input file to allow parsing an include file that > doesn't specify a [section] > > 2) informatively handle case of assignment with no section > > 3) correctly handle getting sections from included files > > 4) assume default bind of 0.0.0.0 > > 5) gracefully handle missing portions of registration string > > 6) Denote steps of operation and confirm top level conf files being > read/written as a convenience > > > Diffs > ----- > > /branches/12/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py 429613 > /branches/12/contrib/scripts/sip_to_pjsip/astconfigparser.py 429613 > > Diff: https://reviewboard.asterisk.org/r/4280/diff/ > > > Testing > ------- > > Ran on config files from various sources to insure no exceptions occurred. > Perused output to confirm appearance of converted input values. > > > Thanks, > > Scott Griepentrog > >
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev