Popular recipes tagged "meta:score=10"http://code.activestate.com/recipes/tags/meta:score=10/2012-12-19T07:12:32-08:00ActiveState Code RecipesOrderedSet (Python) 2012-12-19T07:12:32-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576694-orderedset/ <p style="color: grey"> Python recipe 576694 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/ordered/">ordered</a>, <a href="/recipes/tags/set/">set</a>). Revision 9. </p> <p>Set that remembers original insertion order.</p> Compare speeds of different kinds of access to variables (Python) 2011-08-10T23:54:12-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577834-compare-speeds-of-different-kinds-of-access-to-var/ <p style="color: grey"> Python recipe 577834 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/optimization/">optimization</a>). Revision 5. </p> <p>Compare speeds of locals, nested scopes, global, builtins, instance variables, and class variables.</p> LRU and LFU cache decorators (Python) 2010-08-01T01:19:23-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/498245-lru-and-lfu-cache-decorators/ <p style="color: grey"> Python recipe 498245 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 6. </p> <p>One-line decorator call adds caching to functions with hashable arguments and no keyword arguments. When the maximum size is reached, the least recently used entry or least frequently used entry is discarded -- appropriate for long-running processes which cannot allow caches to grow without bound. Includes built-in performance instrumentation.</p> Module to allow Asynchronous subprocess use on Windows and Posix platforms (Python) 2006-12-01T17:30:02-08:00Josiah Carlsonhttp://code.activestate.com/recipes/users/1241800/http://code.activestate.com/recipes/440554-module-to-allow-asynchronous-subprocess-use-on-win/ <p style="color: grey"> Python recipe 440554 by <a href="/recipes/users/1241800/">Josiah Carlson</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). Revision 10. </p> <p>The 'subprocess' module in Python 2.4 has made creating and accessing subprocess streams in Python relatively convenient for all supported platforms, but what if you want to interact with the started subprocess? That is, what if you want to send a command, read the response, and send a new command based on that response?</p> <p>Now there is a solution. The included subprocess.Popen subclass adds three new commonly used methods: recv(maxsize=None), recv_err(maxsize=None), and send(input), along with a utility method: send_recv(input='', maxsize=None).</p> <p>recv() and recv_err() both read at most maxsize bytes from the started subprocess. send() sends strings to the started subprocess. send_recv() will send the provided input, and read up to maxsize bytes from both stdout and stderr.</p> <p>If any of the pipes are closed, the attributes for those pipes will be set to None, and the methods will return None.</p> <p>v. 1.3 fixed a few bugs relating to *nix support v. 1.4,5 fixed initialization on all platforms, a few bugs relating to Windows support, added two utility functions, and added an example of how to use this module. v. 1.6 fixed linux _recv() and test initialization thanks to Yuri Takhteyev at Stanford. v. 1.7 removed _setup() and __init__() and fixed subprocess unittests thanks to Antonio Valentino. Added 4th argument 'tr' to recv_some(), which is, approximately, the number of times it will attempt to recieve data. Added 5th argument 'stderr' to recv_some(), where when true, will recieve from stderr. Cleaned up some pipe closing. v. 1.8 Fixed missing self. parameter in non-windows _recv method thanks to comment. v. 1.9 Fixed fcntl calls for closed handles.</p> Sorting big files the Python 2.4 way (Python) 2006-04-13T10:43:13-07:00Nicolas Lehuenhttp://code.activestate.com/recipes/users/1599156/http://code.activestate.com/recipes/466302-sorting-big-files-the-python-24-way/ <p style="color: grey"> Python recipe 466302 by <a href="/recipes/users/1599156/">Nicolas Lehuen</a> (<a href="/recipes/tags/files/">files</a>). Revision 6. </p> <p>This recipe can be used to sort big files (much bigger than the available RAM) according to a key. The sort is guaranteed to be stable on Python 2.3.</p> The simple but handy "collector of a bunch of named stuff" class (Python) 2001-04-08T19:08:56-07:00Alex Martellihttp://code.activestate.com/recipes/users/97991/http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/ <p style="color: grey"> Python recipe 52308 by <a href="/recipes/users/97991/">Alex Martelli</a> (<a href="/recipes/tags/oop/">oop</a>). Revision 2. </p> <p>Often we want to just collect a bunch of stuff together, naming each item of the bunch; a dictionary's OK for that, but a small do-nothing class is even handier, and prettier to use.</p>