开发者

file compression without using built in functions

开发者 https://www.devze.com 2023-01-28 14:22 出处:网络
python programmers, I\'m am new to python ,I read that we have built in functions to achieve file compression in python . I just wanted to know if a file compression can be done without using these bu

python programmers, I'm am new to python ,I read that we have built in functions to achieve file compression in python . I just wanted to know if a file compression can be done without using these built in functions (maybe a longer code perhaps) .I wanted to understand the working of these built in functions(how th开发者_如何学Cey are coded) basically . forgive the fallacies(if any) of a beginner, thanks in advance


Well there are lots of different ways to compress data, but it can be quite a task to undertake. One area you might want to research is Huffman Coding which can help with compression, especially for plain text. The reason I point it out is that it is more approachable than other compression techniques, and can be a good starting point.

Sure it is possible to do on your own, but it will be much longer than using pre-built functions and probably not as effective.

If you want to look up the implementation you can find open source libraries and look over the code that actually implements various compression algorithms.

Researching and learning about the code is a great idea, but unless there is a very good reason not to you should stick to using the pre-built modules.


If you would like to learn more about how file compression works, the code is available right in the python source code in the file gzip.py. You should also check out the zlib source code, on which the gzip module is based.

You can get zlib source code from zlib.net.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号