<div dir="ltr">xrange should be more memory efficient than range: <a href="http://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range">http://stackoverflow.com/questions/135041/should-you-always-favor-xrange-over-range</a><div>

<br></div><div>Replacing arrays with lists is probably a bad idea for a lot of reasons.  You'll lose nice vectorization of simple operations, and all of numpy's other benefits.  To be more parsimonious with memory, you probably want to pay close attention to array data types and make sure that things aren't being automatically upconverted to higher precision data types.</div>

<div><br></div><div>I've never considered using reset.  Perhaps you need to take a look at your program's structure and make sure that useless arrays can be garbage collected properly.</div><div><br></div><div>Preallocation of arrays can give you tons of benefits with regards to array size and program speed.  If you aren't using preallocation, now's a great time to start.</div>

<div><br></div><div>You can pass numpy arrays into Cython functions, and you can also call numpy/scipy functions within Cython functions.  Identify your bottlenecks using some kind of profiling, then work on optimizing those with Cython.</div>

<div><br></div><div>HTH,</div><div>Mike</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 26, 2013 at 11:19 AM, Josè Luis Mietta <span dir="ltr"><<a href="mailto:joseluismietta@yahoo.com.ar" target="_blank">joseluismietta@yahoo.com.ar</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:10pt;font-family:times new roman,new york,times,serif"><div> <div>Hi experts!</div><div><br>

</div> <div>I wanna use less RAM memory in my Monte Carlo simulations. In my algorithm I use numpy arrays and <code>xrange()</code> function.</div> <div>I hear that I can reduce RAM used in my lagorithm if I do the next:</div>

<div><br></div> <div>1) replace <code>xrange()</code> for <code>range()</code>. <br></div><div>2) replace numpya arrays for python lists <br></div><div style="font-style:normal;font-size:13.3333px;background-color:transparent;font-family:times new roman,new york,times,serif">

3) use <code>reset()</code> function for deleting useless arrays. <br></div><div style="font-style:normal;font-size:13.3333px;background-color:transparent;font-family:times new roman,new york,times,serif">Is that
 true?</div><div style="font-style:normal;font-size:13.3333px;background-color:transparent;font-family:times new roman,new york,times,serif"><br></div><div style="font-style:normal;font-size:13.3333px;background-color:transparent;font-family:times new roman,new york,times,serif">

In adition, I wanna  increase execution speed of my code (I use numpy and SciPy functions). How can I apply Cython? Will it help?<br></div><div style="font-style:normal;font-size:13.3333px;background-color:transparent;font-family:monospace">

<br></div>  <div>Please help.</div><div><br></div> <div>Thanks a lot!!</div></div><br></div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>