I'm not super-familiar with tarfile, though I did use it in one project.

First off, note that CPython is commonly 4x slower than C.  In fact,
it can be much worse at times.

Also...  Have you considered trying your code on Pypy3?

On Mon, Apr 16, 2018 at 9:10 AM, Jim MacArthur
<jim.macarthur+pyt...@codethink.co.uk> wrote:
> Hi, I'm seeing a very slow extraction of an uncompressed tar file using
> 'tarfile' in Python 3.5.3 vs. the native Debian tar tool. This is a console
> log from my machine:
>
> jimm@scw-000001:~$ time tar xf update.tar
>
> real    0m3.436s
> user    0m0.430s
> sys     0m2.870s
> jimm@scw-000001:~$ rm -rf home
> jimm@scw-000001:~$ cat untar-test.py
> #!/usr/bin/env python3
>
> import tarfile
>
> tar = tarfile.open('update.tar')
>
> tar.extractall()
>
> jimm@scw-000001:~$ time ./untar-test.py
>
> real    0m12.216s
> user    0m8.730s
> sys     0m3.030s
> jimm@scw-000001:~$ uname -a
> Linux scw-000001 4.3.5-std-1 #1 SMP Fri Feb 19 11:52:18 UTC 2016 armv7l
> GNU/Linux
> jimm@scw-000001:~$ python3
> Python 3.5.3 (default, Jan 19 2017, 14:11:04)
> [GCC 6.3.0 20170118] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>>
>>>>
>
> ----
>
> I also tried this with 3.7.0b3 and I get the same result. On my desktop, an
> x86_64 running Ubuntu, there's little difference between tarfile and native
> tar. Obviously there will be some time spent starting Python but the above
> seems too much. Does anyone have any ideas what might cause this or where to
> look next? Does x86_64 do more of this in C code that's interpreted on
> armv7l, for example?
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to