Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1133898iog; Wed, 15 Jun 2022 22:40:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sbhaJ4tLQsMHXKKon8ijQ+ruJEqXj4/QERq6KKqh7+WQbAVzOR/K4jXZgL8w9B5+OLTTKr X-Received: by 2002:a05:6402:b09:b0:42d:bd80:11ac with SMTP id bm9-20020a0564020b0900b0042dbd8011acmr4311019edb.244.1655358044675; Wed, 15 Jun 2022 22:40:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655358044; cv=pass; d=google.com; s=arc-20160816; b=PVUgZOjjjVcqBssBDpgLSqEbY73CmwI+L/osqndDtnK6V5Mc6CtRuyQB1NYSENBNkf s7GOFyDZ5RSO0gM2AgeDYVnAVrYSF9jIQEXvPDUronbx9nrLBwXfEQFWJgLz4qCUDwmP cNT7c/SkbWFybXCl1Tm7Xf97T3d6QBG60u2hWI7GdYK0Pt/jCX2AFHW2SnX1iB/peUFB MP72Ul0dStZRk5I1zfe/TzG0i/6YRhl19rznn9IcD/blx21OqYbVZ1nhVwyQLuI5ukD6 41x6bh3mILIEKkMr3/UXzH+b95KZbFG1DzoR8uBNFGZDmgHctWDhZQs7/ZIgQrDqVzyP 3Jfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:importance:content-transfer-encoding :mime-version:subject:in-reply-to:message-id:cc:to:from:date; bh=SPhGZ2firub1ZFNfQSqHRLLIpyGLrtsyXbIh15hT2/8=; b=q4pA1cT8BdJ2aijCpL7jDc3VnjwTWZGolW0PUPoFqAtMf4SlQjErE0Rsi20hwoi+cN 4xs5yPtTLGwuluglh8MF3ANhD5AoXqB4F4rB2+dxFra/ZYy1yNtcN8dAArE+gaVV/H6S mLxRcDzkuIOYKd1ktMuge67ll4OUHfUiHOjp0pDo/8dVRkhDWhsNhB8eJvcx8NYaqjJ0 QX2zYMcKsy06X7mwf7A8P+MT6DFCYQWIk7TOAGL9nlRaVhbc8xBIbzrmcT9ObexUug1z L7C7TokKWBmY/7I5nBV6Y/zYjxb0irZj5L+aMIFPYEL+AIpiVWqwijE/5mLqVXXkRgSO AxJw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=elijahpepe.com dmarc=pass fromdomain=elijahpepe.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056402510800b0043155ad8daasi1558019edd.603.2022.06.15.22.40.18; Wed, 15 Jun 2022 22:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=elijahpepe.com dmarc=pass fromdomain=elijahpepe.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358917AbiFPFiW (ORCPT + 99 others); Thu, 16 Jun 2022 01:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358727AbiFPFhn (ORCPT ); Thu, 16 Jun 2022 01:37:43 -0400 X-Greylist: delayed 909 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 15 Jun 2022 22:37:42 PDT Received: from sender4-of-o54.zoho.com (sender4-of-o54.zoho.com [136.143.188.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3E913F6C for ; Wed, 15 Jun 2022 22:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655356942; cv=none; d=zohomail.com; s=zohoarc; b=CyY6ToycbNn+zWinEzZEs0D//LT/UQNM1yTp2rHMer0hwQN4tmWfTgqUFVSU4MPLcxr2BOKVwcGUZKUeSALbSOjoSWzAzd3CnTofuFRfuqvdLWTaVMyL3zypuzWUbe7/blkcbJXrre8wfvOkpkrpUel7mTxCsP6BbLy0KTbrbkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655356942; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=SPhGZ2firub1ZFNfQSqHRLLIpyGLrtsyXbIh15hT2/8=; b=Ih+sj9oFQWGcYzm8swXT2KgK6YU4FGTN3NJjLn4f+r25gKboLVXBlm1sjL8l4biL+uAJ73m5sa9UKmnJHWfaYS8vZNFfmaLi6RwwjOaiNlsvcVDiwBKZg/c3NzQ08ZVCUi/o6G9LjmHKYGLVh7X7yYUPWMRjRtOM+gOiO1U5Jt0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass smtp.mailfrom=business@elijahpepe.com; dmarc=pass header.from= Received: from mail.zoho.com by mx.zohomail.com with SMTP id 165535694023895.0045501776118; Wed, 15 Jun 2022 22:22:20 -0700 (PDT) Date: Wed, 15 Jun 2022 22:22:20 -0700 From: Elijah Conners To: "acme" Cc: "peterz" , "mingo" , "linux-perf-users" , "jolsa" , "markrutland" , "alexandershishkin" , "namhyung" , "linux-kernel" Message-ID: <1816af65fb3.cadada251255317.8101049033080913987@elijahpepe.com> In-Reply-To: Subject: [PATCH] scripts: use is None instead of == None MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Importance: Medium User-Agent: Zoho Mail X-Mailer: Zoho Mail X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In compaction-times.py, exported-sql-viewer.py, mem-phys-addr.py, net_dropmonitor.py, kunit.py, and tdc.py, the None object is checked against various variables using equality. This is 50% slower than using an identity operator, since using equality invokes the __eq__ method. Checking identity in this case is also much better form. Signed-off-by: Elijah Conners --- tools/perf/scripts/python/compaction-times.py | 2 +- tools/perf/scripts/python/exported-sql-viewer.py | 2 +- tools/perf/scripts/python/mem-phys-addr.py | 2 +- tools/perf/scripts/python/net_dropmonitor.py | 2 +- tools/testing/kunit/kunit.py | 2 +- tools/testing/selftests/tc-testing/tdc.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/scripts/python/compaction-times.py b/tools/perf/scripts/python/compaction-times.py index 2560a042dc6f..790cc58214a9 100644 --- a/tools/perf/scripts/python/compaction-times.py +++ b/tools/perf/scripts/python/compaction-times.py @@ -31,7 +31,7 @@ class comm_filter: def filter(self, pid, comm): m = self.re.search(comm) - return m == None or m.group() == "" + return m is None or m.group() == "" class pid_filter: def __init__(self, low, high): diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 13f2d8a81610..28b53739746f 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -452,7 +452,7 @@ class FindBar(): index = self.textbox.currentIndex() data = self.textbox.itemData(index) # Store the pattern in the combo box to keep it with the text value - if data == None: + if data is None: self.textbox.setItemData(index, pattern) else: self.pattern.setChecked(data) diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py index 1f332e72b9b0..5891a4df69aa 100644 --- a/tools/perf/scripts/python/mem-phys-addr.py +++ b/tools/perf/scripts/python/mem-phys-addr.py @@ -95,6 +95,6 @@ def process_event(param_dict): phys_addr = sample["phys_addr"] global event_name - if event_name == None: + if event_name is None: event_name = name load_mem_type_cnt[find_memory_type(phys_addr)] += 1 diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py index 101059971738..cd9488f11e03 100755 --- a/tools/perf/scripts/python/net_dropmonitor.py +++ b/tools/perf/scripts/python/net_dropmonitor.py @@ -55,7 +55,7 @@ def print_drop_table(): print("%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")) for i in drop_log.keys(): (sym, off) = get_sym(i) - if sym == None: + if sym is None: sym = i print("%25s %25s %25s" % (sym, off, drop_log[i])) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index 9274c6355809..6195e091d22d 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -496,7 +496,7 @@ def main(argv, linux=None): if result.status != KunitStatus.SUCCESS: sys.exit(1) elif cli_args.subcommand == 'parse': - if cli_args.file == None: + if cli_args.file is None: sys.stdin.reconfigure(errors='backslashreplace') # pytype: disable=attribute-error kunit_output = sys.stdin else: diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py index ee22e3447ec7..f1840023283a 100755 --- a/tools/testing/selftests/tc-testing/tdc.py +++ b/tools/testing/selftests/tc-testing/tdc.py @@ -355,7 +355,7 @@ def test_runner(pm, args, filtered_tests): print('give test rig 2 seconds to stabilize') time.sleep(2) for tidx in testlist: - if "flower" in tidx["category"] and args.device == None: + if "flower" in tidx["category"] and args.device is None: errmsg = "Tests using the DEV2 variable must define the name of a " errmsg += "physical NIC with the -d option when running tdc.\n" errmsg += "Test has been skipped." -- 2.25.1