The answer is here!

Hi,

First of all, I apologize for not posting the answer after I got it.

I posted this question here long back, then my doubt was resolved, and I completely forgot about it. Apologies for same to those who were looking for the answer badly.

The answer is that during compression, several info is needed, which is kept in a header. This header takes up space as well, which increases overall size.

In cases where there is good compresssion, this header size is not significant, and overall compressed text size is smaller than original size.

In this case, the compression was not good (which depend a lot upon the data being used). So the increase due to header size was greater than decrease due to compression.

So, that was the explanation to the apparent 'mystery'.

Keep me posted, and have fun with Python. 

 Bye.

 



An elementary Python data compression question

Hi all,
Though I don't work in data compression, but for learning purpose only I ran a program very similar to the one given in version specific tutorial from www.python.org.  (ch 11, tut.pdf). The two programs are:

PROGRAM 1

import zlib
s = "witch which has which witches wrist watch"
print "Original String is ::%s:: and length of the string is ::%d::" %(s,len(s))
t = zlib.compress(s)
print "Compressed String is ::%s:: and length of the string is ::%d::" %(t,len(t))
print "Decompressed String is ::%s:: and length of the decompressed string is ::%d::" %(zlib.decompress(t),len(zlib.decompress(t)))

PROGRAM 2

import zlib
s = "witch which has which witches wrist watch"
print "Original String is ::%s:: and length of the string is ::%d::" %(s,len(s))
t = zlib.compress(s)
print "Compressed String is ::%s:: and length of the string is ::%d::" %(t,len(t))
print "Decompressed String is ::%s:: and length of the decompressed string is ::%d::" %(zlib.decompress(t),len(zlib.decompress(t)))

Now the problem is that:
in program2, the 'len(t)', i.e. length of the compressed string is greater than length of the original string!!! In program 1, this 'apparent anomaly' doesn't occur, and this is the string used in the python.org tutorial.

Can anybody provide an explanation? At this point, I don't want to read a few hundred pages on data compression to find out the answer.

Thanks in advance,
Abhishek Pathak.



Check out those Python scritpts (new!)

Hi everybody,

I have uploade some of my early python scripts. Go to the album called 'Python scripts' to get more details.

Will write again soon,

Bye. 

 



Hello, check out a few AI and Robotics photos I have uploaded

Hi,

I have uploaded some images related to AI and Robotics. I may sometimes later on upload some of the images I used durin my R&D projects on Image Processing.

 

Till then, enjoy these, and leave some comments regarding how you liked the collection, and whether you would like to see more such stuff here.

 

Bye. 



Welcome to one and all

Hello everybody,

Welcome to all : This is a community to discuss all you need to discuss on Science, Artificial Intelligence, Computer Science, Engineering, Technology, and of course, Python.

Bye. 




Copyright(c) 2017 - PythonBlogs.com
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved