Hacker News new | past | comments | ask | show | jobs | submit login

    $ strace python -c "print('hello world')" 2>&1 > /dev/null | wc -l
    924

    $ strace python3 -c "print('hello world')" 2>&1 > /dev/null | wc -l
    543



Python's site module contributes a lot to this. It attempts to load a lot of other modules, many of which may not exist for a given install.

Using your example:

    $ strace python3 -c 'print("hello world", end="")' 2>&1 | hist
     1. stat                 122
     2. rt_sigaction         68
     3. fstat                67
     4. read                 55
     5. close                47
     6. open                 37
     7. mmap                 34
     8. lseek                30
     9. getdents             18
    10. mprotect             16
        ...                 
        TOTAL:               567

    $ strace python3 -S -c 'print("hello world", end="")' 2>&1 | hist
     1. rt_sigaction         68
     2. stat                 51
     3. fstat                39
     4. mmap                 31
     5. read                 27
     6. close                26
     7. open                 23
     8. mprotect             16
     9. lseek                15
    10. brk                  10
        ...                 
        TOTAL:               350


Wow, that's bad even by interpreted language standards:

  % strace perl -e "print 'Hello, World';" 2>&1 > /dev/null | wc -l
  192




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: