title: Python disable reference counting for some objects
body: <p>This question is derived from <a href="https://stackoverflow.com/q/14124588/898747">here</a>.</p>
  
  <p>I have three large lists containing python objects (<code>l1</code>, <code>l2</code> and <code>l3</code>). These lists are created when the program starts and they take total of 16GB of RAM. The program will be used on linux exclusively.</p>
  
  <p>I do not need to modify these lists or the objects in these lists in any way or form after they are created. They must remain in memory until the program exits.</p>
  
  <p>I am using os.fork() and multiprocessing module in my program to spawn multiple sub-processes (up to 20 currently). Each of these sub-processes needs to be able to read the three lists (<code>l1</code>, <code>l2</code> and <code>l3</code>).</p>
  
  <p>My program is otherwise working fine and quite fast. However i am having problems with memory consumption. I was hoping that each sub-process can use the three lists without copying them in memory due to the copy-on-write approach on Linux. However this is not the case as referencing any object in any of these lists will increase the associated ref counts and therefore causes the entire page of memory to be copied.</p>
  
  <p>So my question would be:</p>
  
  <p>Can i disable the reference counting on <code>l1</code>, <code>l2</code> and <code>l3</code> and all of the objects in these lists? Basically making the entire object (including meta-data such as ref count) read-only, so that it will never be modified under any circumstances (this, i assume, would allow me to take advantage of copy-on-write).</p>
  
  <p>Currently i fear that i am forced to move to another programming language to accomplish this task because of a "feature" (ref counting) that i do not need currently, but what is still forced upon me and causing unnecessary problems.</p>