Popular recipes tagged "memory" but not "datastructures"http://code.activestate.com/recipes/tags/memory-datastructures/2017-07-22T15:52:01-07:00ActiveState Code RecipesCompute Memory footprint of an object and its contents (Python) 2012-11-23T23:57:31-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577504-compute-memory-footprint-of-an-object-and-its-cont/ <p style="color: grey"> Python recipe 577504 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sizeof/">sizeof</a>). Revision 3. </p> <p>Recursive version sys.getsizeof(). Extendable with custom handlers.</p> Compute Memory footprint of an object and its contents (Python) 2014-05-15T13:44:15-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/578880-compute-memory-footprint-of-an-object-and-its-cont/ <p style="color: grey"> Python recipe 578880 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sizeof/">sizeof</a>). </p> <p>Recursive version sys.getsizeof(). Extendable with custom handlers.</p> InMemoryZip class (Python) 2013-09-23T06:44:23-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578667-inmemoryzip-class/ <p style="color: grey"> Python recipe 578667 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/zip/">zip</a>). </p> <p><strong>Why implementing this?</strong></p> <ul> <li>transfering a file or a folder (including sub folders) to another machine</li> <li>therefore zipping content to one compressed buffer</li> <li>keeping the relating ZIP in memory only but ...</li> <li>being able to save or load too</li> <li>and being able to unzip again at target destination</li> </ul> Get memory usage of Windows processes using GetProcessMemoryInfo (via ctypes) (Python) 2013-04-25T01:26:19-07:00Ben Hoythttp://code.activestate.com/recipes/users/4170919/http://code.activestate.com/recipes/578513-get-memory-usage-of-windows-processes-using-getpro/ <p style="color: grey"> Python recipe 578513 by <a href="/recipes/users/4170919/">Ben Hoyt</a> (<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/win32/">win32</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>These functions call the Win32 function GetProcessMemoryInfo() using ctypes to get the memory usage of the current process. Works on both 32-bit and 64-bit Windows and Python 2.6+ (including Python 3.x).</p> Human readable file/memory sizes (Python) 2012-11-05T11:59:20-08:00Tony Fluryhttp://code.activestate.com/recipes/users/4184150/http://code.activestate.com/recipes/578321-human-readable-filememory-sizes/ <p style="color: grey"> Python recipe 578321 by <a href="/recipes/users/4184150/">Tony Flury</a> (<a href="/recipes/tags/formatting/">formatting</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/size/">size</a>). Revision 5. </p> <p>In writing a application to display the file sizes of set of files, I wanted to provide a human readable size rather then just displaying a byte count (which can get rather big).</p> <p>I developed this useful short recipe that extends the format specifier mini Language to add the S presentation type - which will intelligently convert the value to be displayed into a known human readable size format - i.e. b, Kb,Mb, Gb etc. It honours the rest of the format specification language (<a href="http://docs.python.org/2/library/string.html#format-string-syntax%29" rel="nofollow">http://docs.python.org/2/library/string.html#format-string-syntax)</a></p> <p>It uses a factor of 1024 at each stage</p> Human readable file/memory sizes v2 (Python) 2012-11-11T17:28:57-08:00Tony Fluryhttp://code.activestate.com/recipes/users/4184150/http://code.activestate.com/recipes/578323-human-readable-filememory-sizes-v2/ <p style="color: grey"> Python recipe 578323 by <a href="/recipes/users/4184150/">Tony Flury</a> (<a href="/recipes/tags/formatting/">formatting</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/size/">size</a>). </p> <p>In writing a application to display the file sizes of set of files, I wanted to provide a human readable size rather then just displaying a byte count (which can get rather big).</p> <p>I developed this useful short recipe that extends the format specifier mini Language to add new presentation type s- which will intelligently convert the value to be displayed into a known human readable size format - i.e. b, Kb,Mb, Gb, B, KB etc. It honours the rest of the format specification language (<a href="http://docs.python.org/2/library/string.html#format-string-syntax%29" rel="nofollow">http://docs.python.org/2/library/string.html#format-string-syntax)</a></p> <p>It uses a factor of 1024 for IEC and common formats, and factor of 1000 for SI units.</p> For AMIGA-Heads Only. Poking A HW, (Memory), Address On A Classic AMIGA, Inside Text Mode Python. (Python) 2012-09-09T19:25:00-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578255-for-amiga-heads-only-poking-a-hw-memory-address-on/ <p style="color: grey"> Python recipe 578255 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/amiga/">amiga</a>, <a href="/recipes/tags/demo/">demo</a>, <a href="/recipes/tags/e_uae/">e_uae</a>, <a href="/recipes/tags/hardware/">hardware</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/poke/">poke</a>, <a href="/recipes/tags/winuae/">winuae</a>). </p> <p>For AMIGA-Heads Only...</p> <p>This code is purely for a minimum of a stock Classic AMIGA A1200(HD), E-UAE, and WinUAE running AMIGA OS3.0x to 3.1x. It will NOT work on any other platform!</p> <p>(It MIGHT work on AMIGA OS3.5x and 3.9x with Python 2.4.6, but totally untested and I hold no responsibility for the outcome when trying it.)</p> <p>It is a DEMO to poke a byte inside _ANY_ memory address inside the standard CPU 68EC020 16MB boundary.</p> <p>This is not a function nor a class but just a DEMO to show how to write directly to HW, (or memory), addresses.</p> <p>POKING memory or hardware addresses is not recommended for novices without studying the machine first, and, this code will ignore any _ENFORCER_hits_.</p> <p>I experimented with this several years ago and have decided to finally release it. I do await the flak!</p> <p>It works from Python Versions 1.4.0 to 2.0.1 for the classic AMIGA.</p> <p>This is issued as Public Domain and you may do with it as you please.</p> <p>Ensure that the T: Volume exists on the running machine.</p> <p>See inside the code and text below it also as to how it works...</p> <p>Bazza, G0LCU...</p> Whitespace Memory Manager (Python) 2011-07-17T19:45:38-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577673-whitespace-memory-manager/ <p style="color: grey"> Python recipe 577673 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/management/">management</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/whitespace/">whitespace</a>). Revision 3. </p> <p>Related to <a href="http://code.activestate.com/recipes/577108/">recipe 577108</a> and <a href="http://code.activestate.com/recipes/577110/">recipe 577110</a>, this library of functions was written for those that wish to explore more in experimental programming in the Whitespace language (and more specifically, assembly derived from the language). The code is divided into several sections, starting with an explanation of some special memory locations and a list of functions available grouped by their general purpose. Next comes a table of errors that could raised while the code is running and the body of the main test function for the entire program. The next three sections (in order) are three untested functions, the functions intended for usage, and individual test functions for the preceding code. Most of the documentation is written in modified Python to express how all of the code operates.</p> <p>If you have any comments or wish to vote this recipe down, please provide an explanation as to what you find fault with in this program and also a solution that you would implement to fix the problem.</p> Named Sequences for environments containing large numbers of POD instances (Python) 2010-11-27T13:55:18-08:00Kevin L. Sitzehttp://code.activestate.com/recipes/users/4173535/http://code.activestate.com/recipes/577473-named-sequences-for-environments-containing-large-/ <p style="color: grey"> Python recipe 577473 by <a href="/recipes/users/4173535/">Kevin L. Sitze</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/slot/">slot</a>, <a href="/recipes/tags/unittests/">unittests</a>). </p> <p>Generate classes with named data attributes that can be sequenced. Useful for POD classes for which many records will exist concurrently.</p> <p>Compare the feature set to NamedTuples by Raymond Hettinger: <a href="http://code.activestate.com/recipes/500261-named-tuples/" rel="nofollow">http://code.activestate.com/recipes/500261-named-tuples/</a></p> Size of Python objects (revised). (Python) 2017-07-22T15:52:01-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/546530-size-of-python-objects-revised/ <p style="color: grey"> Python recipe 546530 by <a href="/recipes/users/2984142/">Jean Brouwers</a> (<a href="/recipes/tags/getsizeof/">getsizeof</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sizeof/">sizeof</a>). Revision 21. </p> <p>This recipe determines the size of Python objects in bytes and has been further enhanced to handle ints, namedtuples, arrays and NumPy types better. Functions <em>alen</em> and <em>itemsize</em> have been updated. Support for Python 2.5 and earlier and the tests/examples have been removed. See project <a href="https://github.com/pympler/pympler">Pympler</a> for unit tests.</p> <p>See also other, simpler recipes like this <a href="http://code.activestate.com/recipes/577504">Compute memory footprint of an object and its contents</a>.</p> Reading large files from zip archive (Python) 2009-08-17T10:24:40-07:00Volker S.http://code.activestate.com/recipes/users/4171469/http://code.activestate.com/recipes/576882-reading-large-files-from-zip-archive/ <p style="color: grey"> Python recipe 576882 by <a href="/recipes/users/4171469/">Volker S.</a> (<a href="/recipes/tags/large_files/">large_files</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/zip/">zip</a>). Revision 3. </p> <p>The standard zipfile module provides only a method to extract the entire content of a file from within a zip-file. This extension adds a generator method to iterate over the lines in a file, avoiding the memory problems.</p> Track new/unreclaimed objects between 2 points in the code (Python) 2008-10-03T12:14:52-07:00david decotignyhttp://code.activestate.com/recipes/users/4129454/http://code.activestate.com/recipes/576523-track-newunreclaimed-objects-between-2-points-in-t/ <p style="color: grey"> Python recipe 576523 by <a href="/recipes/users/4129454/">david decotigny</a> (<a href="/recipes/tags/cycle/">cycle</a>, <a href="/recipes/tags/garbage/">garbage</a>, <a href="/recipes/tags/leak/">leak</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/reclaim/">reclaim</a>). Revision 3. </p> <p>This module provides 3 ways of detecting which objects have been allocated (methods 1 and 3) or became un-reclaimable (method 2) between 2 points in the code. It can be very useful to detect memory leaks (eg. cycles involving objects with a __del__ method).</p>