snakeoil.tar module¶
fixed up Tarfile implementation
Specifically this grabs a copy of tarfile
and applies a set of
modifications- roughly a 33% memory reduction in usage
Note that this modules initial setup semantics are technically racy- if the python implementation allows for the GIL to be swapped to a different thread during tarfile import (at literally the exact right moment) this version can bleed through. Extremely unlikely chance (haven’t managed to even trigger it once yet), but the potential seems to be there.
In usage, instead of importing tarfile you should just import this module instead. It’s intended to be a drop in replacement.
- class snakeoil.tar.ExFileObject(tarfile, tarinfo)[source]¶
Bases:
ExFileObject
- exceptions = (<class 'OSError'>,)¶
- class snakeoil.tar.TarInfo(name='')[source]¶
Bases:
TarInfo
Customized TarInfo implementation.
Note that this implementation has a locked down set of __slots__. The slotting doesn’t remove the underlying Dict being created (which we still pay memory for), but via using __slots__ we no longer pay the overallocation cost of dicts per TarInfo instance.
- Variables:
buf – deletion and setting are disallowed in this implementation. This is done primarily to avoid having to have >512 bytes per TarInfo object.
gname – same as TarInfo.gname, just interned via a property.
uname – same as TarInfo.uname, just interned via a property.
- property buf¶
- property gname¶
Group name.
- property uname¶
User name.