diff --git a/index.html b/index.html index 12607bd..c8be886 100644 --- a/index.html +++ b/index.html @@ -2034,7 +2034,7 @@ WIKI_URL = 'https://en.wikipedia.org/wiki/Python_(prog version = table.find('th', text='Stable release').next_sibling.strings.__next__() logo_url = table.find('img')['src'] logo = requests.get(f'https:{logo_url}').content - with open(os.path.basename(logo_url), 'wb') as file: + with open('test.png', 'wb') as file: file.write(logo) print(python_url, version) except requests.exceptions.ConnectionError: @@ -2101,8 +2101,8 @@ duration = perf_counter() - start_time

Profiling by Line

# $ pip3 install line_profiler memory_profiler
 @profile
 def main():
-    l = list(range(10000))
-    s = set(range(10000))
+    a = [*range(10000)]
+    b = {*range(10000)}
 main()
 
@@ -2111,16 +2111,16 @@ Line # Hits Time Per Hit % Time Line Contents ======================================================= 1 @profile 2 def main(): - 3 1 955.0 955.0 43.7 l = list(range(10000)) - 4 1 1231.0 1231.0 56.3 s = set(range(10000)) + 3 1 955.0 955.0 43.7 a = [*range(10000)] + 4 1 1231.0 1231.0 56.3 b = {*range(10000)}
$ python3 -m memory_profiler test.py
 Line #         Mem usage      Increment   Line Contents
 =======================================================
      1        37.668 MiB     37.668 MiB   @profile
      2                                    def main():
-     3        38.012 MiB      0.344 MiB       l = list(range(10000))
-     4        38.477 MiB      0.465 MiB       s = set(range(10000))
+     3        38.012 MiB      0.344 MiB       a = [*range(10000)]
+     4        38.477 MiB      0.465 MiB       b = {*range(10000)}
 

Call Graph

Generates a PNG image of the call graph with highlighted bottlenecks:

# $ pip3 install pycallgraph2
 from pycallgraph2 import output, PyCallGraph
@@ -2274,7 +2274,7 @@ frames = []
     y = sum(range(velocity))
     frame = Image.new('L', (WIDTH, WIDTH))
     draw  = ImageDraw.Draw(frame)
-    draw.ellipse(((WIDTH / 2) - R, y, (WIDTH / 2) + R, y + (R * 2)), fill='white')
+    draw.ellipse((WIDTH/2-R, y, WIDTH/2+R, y+R*2), fill='white')
     frames.append(frame)
 frames += reversed(frames[1:-1])
 imageio.mimsave('test.gif', frames, duration=0.03)