Thomas
Thomas

Reputation: 11

file compression without using built in functions

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 they are coded) basically . forgive the fallacies(if any) of a beginner, thanks in advance

Upvotes: 1

Views: 573

Answers (2)

Gavin H
Gavin H

Reputation: 10502

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.

Upvotes: 2

Brent Newey
Brent Newey

Reputation: 4509

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.

Upvotes: 1

Related Questions