From 14e03a37662f52e5a06d5af1b3d5ef1e2d7cba93 Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 28 Jun 2019 07:03:12 +0200 Subject: [PATCH 1/4] Add automated testing using Travis CI The repo switch would need to be turned on at https://travis-ci.com/satwikkansal/wtfpython to enable free automated testing of all code changes. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8d2ea6b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: python +install: pip install flake8 +script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics From a4776a6b672d4fd0f1c4b91e8ca07ddb4537faae Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 2 Jul 2019 15:36:23 +0200 Subject: [PATCH 2/4] Use ==/!= to compare str, bytes, and int literals Identity is not the same thing as equality in Python. $ __[flake8](http://flake8.pycqa.org) . --count --select=E9,F63,F7,F82 --show-source --statistics__ ``` if resp.status_code is 200: ^ 1 F632 use ==/!= to compare str, bytes, and int literals 1 ``` --- irrelevant/generate_contributions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irrelevant/generate_contributions.py b/irrelevant/generate_contributions.py index 136f653..f396f32 100644 --- a/irrelevant/generate_contributions.py +++ b/irrelevant/generate_contributions.py @@ -39,7 +39,7 @@ for handle, issues in contribs.items(): issue_string = ', '.join([issue_format.format(i, i) for i in issues]) resp = requests.get(github_rest_api.format(handle)) name = handle - if resp.status_code is 200: + if resp.status_code == 200: pprint.pprint(resp.json()['name']) else: print(handle, resp.content) @@ -48,4 +48,4 @@ for handle, issues in contribs.items(): handle, issue_string)) -print(table_header + "\n".join(rows_so_far)) \ No newline at end of file +print(table_header + "\n".join(rows_so_far)) From e611f24e7f1b43ec1ec019f49e891504693286e9 Mon Sep 17 00:00:00 2001 From: zachkirsch Date: Wed, 3 Jul 2019 11:39:57 -0400 Subject: [PATCH 3/4] Change constant-folding max from <20 to <=20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9827fc4..0e6fd1c 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ Makes sense, right? * Strings that are not composed of ASCII letters, digits or underscores, are not interned. This explains why `'wtf!'` was not interned due to `!`. Cpython implementation of this rule can be found [here](https://github.com/python/cpython/blob/3.6/Objects/codeobject.c#L19) + When `a` and `b` are set to `"wtf!"` in the same line, the Python interpreter creates a new object, then references the second variable at the same time. If you do it on separate lines, it doesn't "know" that there's already `wtf!` as an object (because `"wtf!"` is not implicitly interned as per the facts mentioned above). It's a compiler optimization and specifically applies to the interactive environment. -+ Constant folding is a technique for [peephole optimization](https://en.wikipedia.org/wiki/Peephole_optimization) in Python. This means the expression `'a'*20` is replaced by `'aaaaaaaaaaaaaaaaaaaa'` during compilation to reduce few clock cycles during runtime. Constant folding only occurs for strings having length less than 20. (Why? Imagine the size of `.pyc` file generated as a result of the expression `'a'*10**10`). [Here's](https://github.com/python/cpython/blob/3.6/Python/peephole.c#L288) the implementation source for the same. ++ Constant folding is a technique for [peephole optimization](https://en.wikipedia.org/wiki/Peephole_optimization) in Python. This means the expression `'a'*20` is replaced by `'aaaaaaaaaaaaaaaaaaaa'` during compilation to reduce few clock cycles during runtime. Constant folding only occurs for strings having length less than or equal to 20. (Why? Imagine the size of `.pyc` file generated as a result of the expression `'a'*10**10`). [Here's](https://github.com/python/cpython/blob/3.6/Python/peephole.c#L288) the implementation source for the same. --- From 12a1ac10cbc83c46eab4aed3b8f2f37593d656da Mon Sep 17 00:00:00 2001 From: Zach Kirsch Date: Wed, 3 Jul 2019 11:46:31 -0400 Subject: [PATCH 4/4] Fix github URL typos in CONTRIBUTORS.md --- CONTRIBUTORS.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7f672ac..a5e440e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,13 +2,13 @@ I'm really grateful to all the contributors. Following are the wonderful people | Contributor | Github | Issues | |-------------|--------|--------| -| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https:/github.com/satwikkansal/wtfpython/issues/36) | -| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https:/github.com/satwikkansal/wtfpython/issues/23) | -| asottile | [asottile](https://github.com/asottile) | [#40](https:/github.com/satwikkansal/wtfpython/issues/40) | -| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https:/github.com/satwikkansal/wtfpython/issues/1) | -| tukkek | [tukkek](https://github.com/tukkek) | [#11](https:/github.com/satwikkansal/wtfpython/issues/11), [#26](https:/github.com/satwikkansal/wtfpython/issues/26) | -| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https:/github.com/satwikkansal/wtfpython/issues/9) | -| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https:/github.com/satwikkansal/wtfpython/issues/32) | -| sohaibfarooqi | [sohaibfarooqi](https://github.com/sohaibfarooqi) | [#63](https:/github.com/satwikkansal/wtfpython/issues/63) | +| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https://github.com/satwikkansal/wtfpython/issues/36) | +| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https://github.com/satwikkansal/wtfpython/issues/23) | +| asottile | [asottile](https://github.com/asottile) | [#40](https://github.com/satwikkansal/wtfpython/issues/40) | +| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https://github.com/satwikkansal/wtfpython/issues/1) | +| tukkek | [tukkek](https://github.com/tukkek) | [#11](https://github.com/satwikkansal/wtfpython/issues/11), [#26](https://github.com/satwikkansal/wtfpython/issues/26) | +| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https://github.com/satwikkansal/wtfpython/issues/9) | +| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https://github.com/satwikkansal/wtfpython/issues/32) | +| sohaibfarooqi | [sohaibfarooqi](https://github.com/sohaibfarooqi) | [#63](https://github.com/satwikkansal/wtfpython/issues/63) | Thank you all for taking out the time to make this project more awesome! :smile: