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
-
Read about data compression, as internally, the python source code will implement gzip, zip, zlib, and bz2 algorithms. In the real world, though, use the standard modules - they are worked on constantly, improved with new versions, heavily used and tested.wkl– wkl2010-12-03 18:40:24 +00:00Commented Dec 3, 2010 at 18:40
2 Answers
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.