Giter VIP home page Giter VIP logo

high_performance_python_2e's People

Contributors

ianozsvald avatar mynameisfiber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

high_performance_python_2e's Issues

Example 3-7 Memory and time consequences of appends versus list comprehensions

Hi, I'm not sure if the code will be added, but in

Example 3-7 Memory and time consequences of appends versus list comprehensions

>>> %memit [i*i for i in range(100_000)]
peak memory: 70.50 MiB, increment: 3.02 MiB

>>> %%memit l = []
... for i in range(100_000):
...     l.append(i * 2)
...
peak memory: 67.47 MiB, increment: 8.17 MiB

it is said "In Example 3-7, we can see that even for 100,000 elements, we use 2.7ร— the memory by building the list with appends versus a list comprehension."

I can not reproduce this with Python 3.8.5.
Neither in a Notebook:

[1]
%load_ext memory_profiler
%load_ext line_profiler
[2]
%memit [i*i for i in range(100_000)]
peak memory: 52.02 MiB, increment: 3.74 MiB
[3]
%%memit 
l = []
for i in range(100_000):
    l.append(i * 2)
peak memory: 52.66 MiB, increment: 2.95 MiB

nor outside a notebook:

Filename: list_append.py

Line #    Mem usage    Increment   Line Contents
================================================
     8     38.5 MiB     38.5 MiB   @profile
     9                             def append_to_list() -> List[int]:
    10                                 """Append to list example."""
    11     38.5 MiB      0.0 MiB       result = []
    12     42.4 MiB      0.0 MiB       for i in range(100_000):
    13     42.4 MiB      0.3 MiB           result.append(i * 2)
    14     42.4 MiB      0.0 MiB       return result


Filename: list_append.py

Line #    Mem usage    Increment   Line Contents
================================================
    17     39.4 MiB     39.4 MiB   @profile
    18                             def comp() -> List[int]:
    19                                 """Comprehend example."""
    20     42.2 MiB      0.2 MiB       return [i * i for i in range(100_000)]

Same is true for larger lists:

[2]
%memit [i*i for i in range(100_000_000)]
peak memory: 3849.21 MiB, increment: 3801.23 MiB

[3]
%%memit 
l = []
for i in range(100_000_000):
    l.append(i * 2)
peak memory: 3912.98 MiB, increment: 3863.53 MiB

Typo: 'local namespace' should be 'global namespace' on page 117

Thanks for the excellent book! I'm enjoying working my way through it.

In Example 6.5 on page 117, I think the following sentence:

This statement takes such a long time per hit because grid_shape must be retrieved from the local namespace

should read:

This statement takes such a long time per hit because grid_shape must be retrieved from the global namespace

Will the code be provided?

Hi there. Thanks for writing the book. This is just a friendly question of whether or not the code for 2e will be available at some moment. I noticed this repo contains many empty directories etc and appears to be scaffolding

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.