Account

Log in (OpenID enabled)
Register

Memory Size of Python Objects

People have wanted to know the size of Python objects for a long time, but before they had to dig into the source code. With the new function sys.getsizeof, you don’t have to.

Here are a list of sizes in bytes of common Python 2.6 datatypes. (containers are empty).

Type 32-bit 64-bit
int  12  24
long (1L)  16  32
float  16  24
tuple  28  56
list  36  72
dict 140 280
old class  48  96
old instance  36  72
new class 452 904
new instance  32  64
function  60 120
lambda  60 120
module  28  56
ascii 'a'  25  41
unicode 'a'  28  56
ascii 'ab'  26  42
unicode 'ab'  30  60

If you want to see a neat application of getsizeof, take a look at this hack.

int         12
  • Reddit
  • Facebook
  • Google Bookmarks
  • RSS

1 Comment


Getting Rich with AdSense $0.00 at a time.

I’ve heard that its against the TOS to mention AdSense earnings, but I don’t think $0.00 qualifies as earnings (never mind, I can disclose “gross payments”).

0earnings

The varying levels of $0.00. During this time around 5000visits were received.

I was hoping that I could use this to sustain the hosting, but at these rates, it could be 100 years before I see payment. I am now wondering if I should remove them but it might not matter anyway since about 40% of visitors use ad block.

At least my account hasn’t been suspended like Hizook. Or maybe the $0.00 is another way of showing it.

  • Reddit
  • Facebook
  • Google Bookmarks
  • RSS

2 Comments


Reddit Censors Atheism Category from Front Page

I had always thought that Reddit would be more resistant to the censorship that plagues Digg (such as the AACS ban and white-listing a select few sites that control 46% of Digg).

redditpope

Unfortunately this was proved wrong today.

Read the rest of this entry »

  • Reddit
  • Facebook
  • Google Bookmarks
  • RSS

2 Comments


Backlash From Stackoverflow Reputation Tips

I recently posted 6 Stackoverflow reputation tips here. I knew there would be some criticism, but the amount of hate was beyond my expectations. There were people threatening to have me banned including one admin.

You would think that I was the Antichrist by some of the comments I had received.

urwrong

I thank Jeff for diffusing some of the negative reactions here, but I think he must have received flack for it since he came out with this statement on Twitter and did not respond to my comment on SO meta:

the gaming stack overflow user has been discussed. But at 7 months, 68 questions, and 325 answers, who is gaming who, again? :)

- Jeff Atwood on Twitter.

This same sentiment of Stackoverflow being the winner and me being the loser was also repeated here. It made me realize that I had not gotten the point clearly enough to them, so here I will try to re-explain my position.

Read the rest of this entry »

  • Reddit
  • Facebook
  • Google Bookmarks
  • RSS

2 Comments


When is Linear Search Faster than Binary Search?

Thanks to Donald Knuth, CS students and programmers know about Big O notation.

Unfortunately with all the years of academic brainwashing or glossing over, people think that Big O is all that matters and look at you funny if you dare to even mention substandard algorithms like linear search.

Formal Definition of Big O

Many people forget that M and X0 can make a big difference.

Read the rest of this entry »

  • Reddit
  • Facebook
  • Google Bookmarks
  • RSS

Leave a Comment