Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: how to optimize the below code with a helper function Date: Mon, 4 Apr 2016 13:34:59 +0530 Lines: 40 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 8llzv4V1PSChJZXrOGsgHwAvY2aGzJaKTQtuaBDB63aw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.061 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'subject:code': 0.07; 'advance': 0.10; 'python': 0.10; '8bit%:26': 0.16; 'function?': 0.16; 'i.e': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'helper': 0.18; 'team,': 0.18; 'variable': 0.18; 'to:name:python- list@python.org': 0.20; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; '8bit%:2': 0.29; 'code': 0.30; 'call.': 0.30; 'optimize': 0.33; 'similar': 0.33; 'case,': 0.34; 'handle': 0.34; 'received:google.com': 0.35; '8bit%:4': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'thanks': 0.37; '(2)': 0.37; 'received:209': 0.38; '(1)': 0.38; 'skip:o 20': 0.38; 'test': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'subject:with': 0.40; 'sample': 0.63; 'times': 0.63; '8bit%:27': 0.72; '8bit%:40': 0.72; '100': 0.79; '8bit%:24': 0.84; 'subject:below': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=OJjIMkHiSZ01YOuclNn72JcM8c0eryH2zLS6swrVOiU=; b=EqOROUZxLKM3mBJdfxTsy7XYkEzepTkLfEX+f/UqxBO344c3IXYnXxDyq5oCyZ222+ fWn3NO53Bdeqy5vcv6IbGTCwZRQG/C7rFzzgbMW0HZWROuJVXcUJxUL8vpZCDQ/hnIpk 1BXgc/oXA6ccGcFPIpZeBJ0AKQFN7tAPGARyonjeOv7Q+NyhZOKoSI4+GZX6415cqsR7 11i58tYgCTqsGFsyXQJHr7S7zzL+6d3OCdsky3U9Gf1aJBuS06+QelpVMVUvVNXLvS9Z M1prp0L+VUCUROo21kJlM9+6vGf+rfVlhahrVx5VMexvHHpgzdNDxxHM6GEd3ZV+GWOI 6IWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=OJjIMkHiSZ01YOuclNn72JcM8c0eryH2zLS6swrVOiU=; b=l+c/8n3ElQByyconboL8G5u9NeBaCDTo3/MDwSMDB74uqN6DexggrRDlrRK6Ymj+Yv NeecHaP8O59FVt9aUYgl0H0uBRP6anZQPPQFc+3iX5za1W1hDIMgfLliYvUXNwqiMvuU 1d49ZEON4UjgTkMuKKt8ImNRYfuxcoRJNOTESmEN/GnJhisCdFTPdip2Fek/OvVbMqQ4 4CdaV9FGIbzXKaB1985RQa00ZZciWht5vnRhvrImdJbRVFGWKXtECiKqg6PEiwc9TwjR LL0sVI3yKcLnas4zxksAZls0nlSx7zRFR9+CVrlYNSui43C8VgjDmRApLFygbVxvOj9y 3vkg== X-Gm-Message-State: AD7BkJLcJu7sAa3UW8bFRuYP+ycprT4DErQ/rGlu5ahisQtVOqaBOa5Zpsf0r8eEz7ZSAAlTknPnaPZ1gHKx1w== X-Received: by 10.25.20.106 with SMTP id k103mr3294697lfi.149.1459757099881; Mon, 04 Apr 2016 01:04:59 -0700 (PDT) X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: Xref: csiph.com comp.lang.python:106427 Hi Team, Iam on python 2.7.10 and Linux. I have a python function where the similar kind of pattern repeating 100 of times Sample code snippet: test01_log = os.path.join(LOG_DIR, "test01.log") cls.get_baddr['test01'] = failure.run_tool( test01_log, object="inode", offset="18", size="4", optype="set") test02_log = os.path.join(LOG_DIR, "test02.log") cls.get_baddr['test02'] = failure.run_tool( test02_log, lin=lin_02, object="lin", offset="100", size="5", optype="set") ..............................................------------------------ test100_log = os.path.join(LOG_DIR, "test100.log") cls.get_baddr['test100'] = failure.run_tool( test02_log, baddr=lin_02, object="baddr", offset="100", size="5", optype="set") (1) Any tips how I can optimize this i.e test case, should have a helper function that all test cases call. (2) Also note that failure.run_tool function can have variable number of argments how to handle this in the helper function? Thanks in advance Regards, Ganesh