Commits

Hong Minhee committed aa3c82e

futureutils 1.1

Comments (0)

Files changed (5)

futureutils/_sources/index.txt

 API
 ---
 
+.. data:: futureutils.DEFAULT_BUFFER_SIZE
+
+   Promised iterators have their own buffer queue internally, and every queue
+   has their maximum size. It intends to avoid wasting memory unlimitedly in
+   case of infinite iterators.
+
+   This constant is a default size of a queue.
+
+.. data:: futueutils.SIGNAL_YIELD
+.. data:: futueutils.SIGNAL_RAISE
+.. data:: futueutils.SIGNAL_RETURN
+.. data:: futueutils.SIGNAL_CONTINUE
+
+   The internal-use only flag constants.
+
 .. autofunction:: futureutils.promise
 
 .. autofunction:: futureutils.future_generator

futureutils/index.html

   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     
-    <title>futureutils — Introduces futures and promises into iterators &mdash; futureutils 1.0</title>
+    <title>futureutils — Introduces futures and promises into iterators &mdash; futureutils 1.1</title>
     <link rel="stylesheet" href="_static/nature.css" type="text/css" />
     <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
     <script type="text/javascript">
       var DOCUMENTATION_OPTIONS = {
         URL_ROOT:    '',
-        VERSION:     '1.0',
+        VERSION:     '1.1',
         COLLAPSE_INDEX: false,
         FILE_SUFFIX: '.html',
         HAS_SOURCE:  true
     <script type="text/javascript" src="_static/jquery.js"></script>
     <script type="text/javascript" src="_static/underscore.js"></script>
     <script type="text/javascript" src="_static/doctools.js"></script>
-    <link rel="top" title="futureutils 1.0" href="#" /> 
+    <link rel="top" title="futureutils 1.1" href="#" /> 
   </head>
   <body>
     <div class="related">
       <h3>Navigation</h3>
       <ul>
-        <li><a href="#">futureutils 1.0</a> &raquo;</li> 
+        <li><a href="#">futureutils 1.1</a> &raquo;</li> 
       </ul>
     </div>  
 
 </div>
 <div class="section" id="api">
 <h2>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h2>
+<dl class="data">
+<dt id="futureutils.futureutils.DEFAULT_BUFFER_SIZE">
+<tt class="descclassname">futureutils.</tt><tt class="descname">DEFAULT_BUFFER_SIZE</tt><a class="headerlink" href="#futureutils.futureutils.DEFAULT_BUFFER_SIZE" title="Permalink to this definition">¶</a></dt>
+<dd><p>Promised iterators have their own buffer queue internally, and every queue
+has their maximum size. It intends to avoid wasting memory unlimitedly in
+case of infinite iterators.</p>
+<p>This constant is a default size of a queue.</p>
+</dd></dl>
+
+<dl class="data">
+<dt id="futureutils.futueutils.SIGNAL_YIELD">
+<tt class="descclassname">futueutils.</tt><tt class="descname">SIGNAL_YIELD</tt><a class="headerlink" href="#futureutils.futueutils.SIGNAL_YIELD" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="data">
+<dt id="futureutils.futueutils.SIGNAL_RAISE">
+<tt class="descclassname">futueutils.</tt><tt class="descname">SIGNAL_RAISE</tt><a class="headerlink" href="#futureutils.futueutils.SIGNAL_RAISE" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="data">
+<dt id="futureutils.futueutils.SIGNAL_RETURN">
+<tt class="descclassname">futueutils.</tt><tt class="descname">SIGNAL_RETURN</tt><a class="headerlink" href="#futureutils.futueutils.SIGNAL_RETURN" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="data">
+<dt id="futureutils.futueutils.SIGNAL_CONTINUE">
+<tt class="descclassname">futueutils.</tt><tt class="descname">SIGNAL_CONTINUE</tt><a class="headerlink" href="#futureutils.futueutils.SIGNAL_CONTINUE" title="Permalink to this definition">¶</a></dt>
+<dd><p>The internal-use only flag constants.</p>
+</dd></dl>
+
 <dl class="function">
 <dt id="futureutils.promise">
-<tt class="descclassname">futureutils.</tt><tt class="descname">promise</tt><big>(</big><em>iterable</em><big>)</big><a class="headerlink" href="#futureutils.promise" title="Permalink to this definition">¶</a></dt>
+<tt class="descclassname">futureutils.</tt><tt class="descname">promise</tt><big>(</big><em>iterable</em>, <em>buffer_size=100</em><big>)</big><a class="headerlink" href="#futureutils.promise" title="Permalink to this definition">¶</a></dt>
 <dd><p>Promises the passed <tt class="docutils literal"><span class="pre">iterable</span></tt> object and returns its future
 iterator.</p>
 <div class="highlight-pycon"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">time</span><span class="o">,</span> <span class="nn">datetime</span>
 <span class="gr">Exception</span>: <span class="n">future error</span>
 </pre></div>
 </div>
+<p>It can deal with infinite iterators as well also:</p>
+<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">itertools</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="n">it</span> <span class="o">=</span> <span class="n">promise</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">cycle</span><span class="p">(</span><span class="s">&#39;Hong Minhee &#39;</span><span class="p">))</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="s">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">it</span><span class="p">,</span> <span class="mi">23</span><span class="p">))</span>
+<span class="go">&#39;Hong Minhee Hong Minhee&#39;</span>
+</pre></div>
+</div>
+<p>Every future iterator has its own buffer queue that stores iterator&#8217;s
+result internally, and every queue has their maximum size. It intends
+to avoid wasting memory unlimitedly in case of infinite iterators.
+You can tune the queue buffer size through <tt class="docutils literal"><span class="pre">buffer_size</span></tt> option.</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">itertools</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">infloop</span><span class="p">():</span>
+<span class="gp">... </span>    <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
+<span class="gp">... </span>    <span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
+<span class="gp">... </span>        <span class="k">print</span> <span class="n">i</span>
+<span class="gp">... </span>        <span class="k">yield</span> <span class="n">i</span>
+<span class="gp">... </span>        <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
+<span class="gp">...</span>
+<span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">promise</span><span class="p">(</span><span class="n">infloop</span><span class="p">(),</span> <span class="n">buffer_size</span><span class="o">=</span><span class="mi">5</span><span class="p">),</span> <span class="mi">5</span><span class="p">)</span>
+<span class="gp">... </span><span class="p">)</span>  
+<span class="go">0</span>
+<span class="go">1</span>
+<span class="go">2</span>
+<span class="go">3</span>
+<span class="go">4</span>
+<span class="gp">...</span>
+<span class="go">[0, 1, 2, 3, 4]</span>
+</pre></div>
+</div>
 <table class="docutils field-list" frame="void" rules="none">
 <col class="field-name" />
 <col class="field-body" />
 <tbody valign="top">
-<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><strong>iterable</strong> (<em>iterable object</em>) &#8211; an iterable object to promise</td>
+<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
+<li><strong>iterable</strong> (<em>iterable object</em>) &#8211; an iterable object to promise</li>
+<li><strong>buffer_size</strong> (<a class="reference external" href="http://docs.python.org/library/functions.html#int" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">int()</span></tt></a>, <a class="reference external" href="http://docs.python.org/library/functions.html#long" title="(in Python v2.7)"><tt class="xref py py-func docutils literal"><span class="pre">long()</span></tt></a>) &#8211; it has its own buffer queue that stores iterator&#8217;s
+result internally, and every queue has their maximum
+size. it intends to avoid wasting too many memory.
+by default it follows the constant
+<a class="reference internal" href="#futureutils.futureutils.DEFAULT_BUFFER_SIZE" title="futureutils.futureutils.DEFAULT_BUFFER_SIZE"><tt class="xref py py-const docutils literal"><span class="pre">DEFAULT_BUFFER_SIZE</span></tt></a></li>
+</ul>
+</td>
 </tr>
-<tr class="field"><th class="field-name">Returns:</th><td class="field-body">a promised future iterator</td>
+<tr class="field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">a promised future iterator</p>
+</td>
 </tr>
-<tr class="field"><th class="field-name">Return type:</th><td class="field-body">iterable object</td>
+<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">iterable object</p>
+</td>
 </tr>
 </tbody>
 </table>
     <div class="related">
       <h3>Navigation</h3>
       <ul>
-        <li><a href="#">futureutils 1.0</a> &raquo;</li> 
+        <li><a href="#">futureutils 1.1</a> &raquo;</li> 
       </ul>
     </div>
     <div class="footer">

futureutils/objects.inv

Binary file modified.

futureutils/search.html

   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     
-    <title>Search &mdash; futureutils 1.0</title>
+    <title>Search &mdash; futureutils 1.1</title>
     <link rel="stylesheet" href="_static/nature.css" type="text/css" />
     <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
     <script type="text/javascript">
       var DOCUMENTATION_OPTIONS = {
         URL_ROOT:    '',
-        VERSION:     '1.0',
+        VERSION:     '1.1',
         COLLAPSE_INDEX: false,
         FILE_SUFFIX: '.html',
         HAS_SOURCE:  true
     <script type="text/javascript" src="_static/underscore.js"></script>
     <script type="text/javascript" src="_static/doctools.js"></script>
     <script type="text/javascript" src="_static/searchtools.js"></script>
-    <link rel="top" title="futureutils 1.0" href="index.html" />
+    <link rel="top" title="futureutils 1.1" href="index.html" />
   <script type="text/javascript">
     jQuery(function() { Search.loadIndex("searchindex.js"); });
   </script>
     <div class="related">
       <h3>Navigation</h3>
       <ul>
-        <li><a href="index.html">futureutils 1.0</a> &raquo;</li> 
+        <li><a href="index.html">futureutils 1.1</a> &raquo;</li> 
       </ul>
     </div>  
 
     <div class="related">
       <h3>Navigation</h3>
       <ul>
-        <li><a href="index.html">futureutils 1.0</a> &raquo;</li> 
+        <li><a href="index.html">futureutils 1.1</a> &raquo;</li> 
       </ul>
     </div>
     <div class="footer">

futureutils/searchindex.js

-Search.setIndex({objects:{"":{futureutils:[0,0,1]},futureutils:{promise:[0,1,1],future_generator:[0,1,1]}},terms:{all:0,concept:0,just:0,api:0,becaus:0,report:0,future_gener:0,sleep:0,follow:0,trivial:0,yet:0,paramet:0,style:0,except:0,former:0,under:0,introduc:0,futur:0,xpath:0,startswith:0,sourc:0,"return":0,python:0,pypi:0,easy_instal:0,cannot:0,promis:0,veri:0,now:0,"class":0,like:0,name:0,docutil:0,list:0,iter:0,easili:0,href:0,found:0,page:0,see:0,yield:0,pass:0,what:0,item:0,pep:0,written:0,tracker:0,"import":0,refer:0,run:0,gener:0,xrang:0,usag:0,onli:0,parallelized_iter:0,repositori:0,span:0,care:0,last:0,could:0,traceback:0,unfortun:0,list_href:0,myiter:0,microsecond:0,chang:0,parallel:0,support:0,semant:0,futureutil:0,effici:0,can:0,appli:0,modul:0,bound:0,automat:0,alreadi:0,strip:0,wrap:0,instal:0,your:0,code:0,from:0,wai:0,licens:0,visit:0,two:0,wrapper:0,next:0,mercuri:0,start:0,interfac:0,inner:0,call:0,type:0,more:0,"function":0,org:0,poorit:0,lower:0,warn:0,mygener:0,pars:0,delta:0,dahlia:0,"true":0,easiest:0,"case":0,made:0,cpython:0,provid:0,setup:0,work:0,second:0,url:0,whatev:0,behavior:0,error:0,def:0,result:0,pre:0,propag:0,well:0,dure:0,doesn:0,liter:0,simpli:0,want:0,pip:0,sever:0,probabl:0,alwai:0,hong:0,lxml:0,welcom:0,datetim:0,latter:0,detail:0,same:0,also:0,html:0,take:0,which:0,you:0,simpl:0,mit:0,higher:0,http:0,distribut:0,normal:0,clone:0,object:0,decor:0,most:0,rais:0,plan:0,why:0,recent:0,bitbucket:0,bug:0,read:0,author:0,minhe:0,doe:0,issu:0,thi:0,time:0,callabl:0,make:0},objtypes:{"0":"py:module","1":"py:function"},titles:["<tt class=\"docutils literal\"><span class=\"pre\">futureutils</span></tt> &#8212; Introduces futures and promises into iterators"],objnames:{"0":"Python module","1":"Python function"},filenames:["index"]})
+Search.setIndex({objects:{"":{futureutils:[0,0,1]},"futureutils.futureutils":{DEFAULT_BUFFER_SIZE:[0,2,1]},futureutils:{promise:[0,1,1],future_generator:[0,1,1]},"futureutils.futueutils":{SIGNAL_RAISE:[0,2,1],SIGNAL_YIELD:[0,2,1],SIGNAL_RETURN:[0,2,1],SIGNAL_CONTINUE:[0,2,1]}},terms:{all:0,future_gener:0,just:0,from:0,becaus:0,report:0,code:0,sleep:0,follow:0,trivial:0,yet:0,paramet:0,style:0,except:0,former:0,lower:0,tracker:0,default_buffer_s:0,under:0,islic:0,introduc:0,take:0,startswith:0,sourc:0,"return":0,whatev:0,python:0,pypi:0,easy_instal:0,cannot:0,promis:0,veri:0,now:0,"class":0,name:0,like:0,docutil:0,signal_rais:0,list:0,iter:0,easili:0,alreadi:0,found:0,inter:[],page:0,deal:0,maximum:0,second:0,signal_return:0,result:0,pass:0,intend:0,infinit:0,index:[],what:0,item:0,avoid:0,pep:0,written:0,version:[],print:0,"import":0,refer:0,run:0,gener:0,xrang:0,usag:0,onli:0,parallelized_iter:0,itertool:0,cycl:0,repositori:0,org:0,care:0,search:[],last:0,could:0,traceback:0,through:0,unfortun:0,queue:0,datetim:0,myiter:0,microsecond:0,doctest:0,mani:0,chang:0,support:0,semant:0,own:0,effici:0,propag:0,appli:0,modul:0,bound:0,automat:0,ellipsi:0,api:0,"long":0,strip:0,wrap:0,instal:0,your:0,size:0,signal_yield:0,span:0,wai:0,memori:0,licens:0,visit:0,two:0,wrapper:0,next:0,mercuri:0,start:0,call:0,too:0,interfac:0,type:0,store:0,inner:0,xpath:0,option:0,futureutil:0,poorit:0,yield:0,warn:0,provid:0,mygener:0,pars:0,doesn:0,delta:0,dahlia:0,"true":0,easiest:0,"case":0,made:0,join:0,cpython:0,"default":0,setup:0,work:0,intern:0,url:0,"while":0,can:0,behavior:0,error:0,futueutil:0,more:0,def:0,pre:0,"function":0,constant:0,have:0,"int":0,signal_continu:0,dure:0,unlimitedli:0,indic:[],liter:0,implement:[],href:0,want:0,tabl:[],pip:0,everi:0,sever:0,probabl:0,concept:0,alwai:0,hong:0,lxml:0,wast:0,welcom:0,list_href:0,make:0,detail:0,same:0,also:0,html:0,futur:0,which:0,buffer_s:0,you:0,simpl:0,mit:0,higher:0,minhe:0,http:0,distribut:0,see:0,normal:0,buffer:0,clone:0,object:0,decor:0,most:0,rais:0,infloop:0,plan:0,parallel:0,tune:0,recent:0,bitbucket:0,bug:0,read:0,author:0,well:0,flag:0,doe:0,issu:0,simpli:0,thi:0,time:0,callabl:0,why:0,latter:0,latest:[]},objtypes:{"0":"py:module","1":"py:function","2":"py:data"},titles:["<tt class=\"docutils literal\"><span class=\"pre\">futureutils</span></tt> &#8212; Introduces futures and promises into iterators"],objnames:{"0":"Python module","1":"Python function","2":"Python data"},filenames:["index"]})