> On Sept. 12, 2017, 1:07 p.m., Dmytro Grinenko wrote: > > ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py > > Lines 145 (patched) > > <https://reviews.apache.org/r/62226/diff/2/?file=1819598#file1819598line145> > > > > while map function is present in python, using generators is more > > prefferable > > Jonathan Hurley wrote: > I've never used generators before - the syntax looks a bit cumbersome for > what's needed here. Can you provide an example of what a generator to trim a > string would look like? > > Dmytro Grinenko wrote: > return (s.strip() for s in stdout.splitlines()) # this would return > gerator, which supports iterative interface > > pros: > - actuall method execution would be issues only when you will call > iterator, each result would return via "yield" (code would run only once) > > cons: > - this would be not list, so no index accessing and only one cycle > > return [s.strip() for s in stdout.splitlines()] # this would return > list > - this will return list > > Dmytro Grinenko wrote: > however for python36, it looks that map is faster that list comphersation > :) > > Jonathan Hurley wrote: > Hah! I changed it. If you'd like me to switch it back, let me know.
sience the day, when we will move to python 3.x is even not on horizon, it is fine to stay with generators/list comphersation - Dmytro ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/62226/#review185174 ----------------------------------------------------------- On Sept. 12, 2017, 2:21 p.m., Jonathan Hurley wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/62226/ > ----------------------------------------------------------- > > (Updated Sept. 12, 2017, 2:21 p.m.) > > > Review request for Ambari, Dmytro Grinenko, Dmitro Lisnichenko, and Nate Cole. > > > Bugs: AMBARI-21931 > https://issues.apache.org/jira/browse/AMBARI-21931 > > > Repository: ambari > > > Description > ------- > > There are several "INVALID" types listed in the stack_packages.json file. > These were placeholders that need to be updated with the packages exposed by > the stack-select tool. > > {code} > ... > "HDFS_CLIENT": { > "STACK-SELECT-PACKAGE": "hadoop-client", > "INSTALL": [ > "hadoop-client" > ], > "PATCH": [ > "INVALID" > ], > "STANDARD": [ > "hadoop-client" > ] > }, > ... > {code} > > > Diffs > ----- > > > ambari-common/src/main/python/resource_management/libraries/functions/stack_select.py > eac1bef13c > > ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_packages.json > 704fb54293 > ambari-server/src/test/python/TestStackSelect.py 3d4e5b6a43 > ambari-server/src/test/python/stacks/utils/RMFTestCase.py 0341092b69 > > > Diff: https://reviews.apache.org/r/62226/diff/3/ > > > Testing > ------- > > ---------------------------------------------------------------------- > Total run:1191 > Total errors:0 > Total failures:0 > OK > [INFO] > ------------------------------------------------------------------------ > [INFO] BUILD SUCCESS > [INFO] > ------------------------------------------------------------------------ > [INFO] Total time: 58.379 s > [INFO] Finished at: 2017-09-11T16:25:26-04:00 > [INFO] Final Memory: 21M/619M > [INFO] > ------------------------------------------------------------------------ > > > Thanks, > > Jonathan Hurley > >
