-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,123 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: a345c9ff2db146449973423b31342d02 | ||
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: f7d200915b7b550f5c004e266578c90b | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,12 @@ | |
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>cached_property — Princeton Prosody Archive 3.13.2 documentation</title> | ||
<title>cached_property — Princeton Prosody Archive 3.14.0 documentation</title> | ||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" /> | ||
<link rel="stylesheet" type="text/css" href="../_static/basic.css?v=c058f7c8" /> | ||
<link rel="stylesheet" type="text/css" href="../_static/basic.css?v=686e5160" /> | ||
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=27fed22d" /> | ||
<script src="../_static/documentation_options.js?v=f92f4e34"></script> | ||
<script src="../_static/doctools.js?v=9a2dae69"></script> | ||
<script src="../_static/documentation_options.js?v=e4f4b189"></script> | ||
<script src="../_static/doctools.js?v=9bcbadda"></script> | ||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script> | ||
<link rel="index" title="Index" href="../genindex.html" /> | ||
<link rel="search" title="Search" href="../search.html" /> | ||
|
@@ -31,24 +31,18 @@ | |
<div class="body" role="main"> | ||
|
||
<h1>Source code for cached_property</h1><div class="highlight"><pre> | ||
<span></span><span class="c1"># -*- coding: utf-8 -*-</span> | ||
|
||
<span class="n">__author__</span> <span class="o">=</span> <span class="s2">"Daniel Greenfeld"</span> | ||
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">"[email protected]"</span> | ||
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">"1.5.2"</span> | ||
<span></span><span class="n">__author__</span> <span class="o">=</span> <span class="s2">"Daniel Roy Greenfeld"</span> | ||
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">"[email protected]"</span> | ||
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">"2.0.1"</span> | ||
<span class="n">__license__</span> <span class="o">=</span> <span class="s2">"BSD"</span> | ||
|
||
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">wraps</span> | ||
<span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">time</span> | ||
<span class="kn">import</span> <span class="nn">threading</span> | ||
|
||
<span class="k">try</span><span class="p">:</span> | ||
<span class="kn">import</span> <span class="nn">asyncio</span> | ||
<span class="k">except</span> <span class="p">(</span><span class="ne">ImportError</span><span class="p">,</span> <span class="ne">SyntaxError</span><span class="p">):</span> | ||
<span class="n">asyncio</span> <span class="o">=</span> <span class="kc">None</span> | ||
<span class="kn">import</span> <span class="nn">asyncio</span> | ||
|
||
|
||
<span class="k">class</span> <span class="nc">cached_property</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> | ||
<span class="k">class</span> <span class="nc">cached_property</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> A property that is only computed once per instance and then replaces itself</span> | ||
<span class="sd"> with an ordinary attribute. Deleting the attribute resets the property.</span> | ||
|
@@ -63,15 +57,14 @@ <h1>Source code for cached_property</h1><div class="highlight"><pre> | |
<span class="k">if</span> <span class="n">obj</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> | ||
<span class="k">return</span> <span class="bp">self</span> | ||
|
||
<span class="k">if</span> <span class="n">asyncio</span> <span class="ow">and</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">iscoroutinefunction</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">):</span> | ||
<span class="k">if</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">iscoroutinefunction</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_wrap_in_coroutine</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> | ||
|
||
<span class="n">value</span> <span class="o">=</span> <span class="n">obj</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="o">.</span><span class="vm">__name__</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> | ||
<span class="k">return</span> <span class="n">value</span> | ||
|
||
<span class="k">def</span> <span class="nf">_wrap_in_coroutine</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span> | ||
<span class="nd">@wraps</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span> | ||
<span class="nd">@asyncio</span><span class="o">.</span><span class="n">coroutine</span> | ||
<span class="k">def</span> <span class="nf">wrapper</span><span class="p">():</span> | ||
<span class="n">future</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">ensure_future</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">obj</span><span class="p">))</span> | ||
<span class="n">obj</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="o">.</span><span class="vm">__name__</span><span class="p">]</span> <span class="o">=</span> <span class="n">future</span> | ||
|
@@ -80,7 +73,7 @@ <h1>Source code for cached_property</h1><div class="highlight"><pre> | |
<span class="k">return</span> <span class="n">wrapper</span><span class="p">()</span> | ||
|
||
|
||
<span class="k">class</span> <span class="nc">threaded_cached_property</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> | ||
<span class="k">class</span> <span class="nc">threaded_cached_property</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> A cached_property version for use in environments where multiple threads</span> | ||
<span class="sd"> might concurrently try to access the property.</span> | ||
|
@@ -107,7 +100,7 @@ <h1>Source code for cached_property</h1><div class="highlight"><pre> | |
<span class="k">return</span> <span class="n">obj_dict</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">obj</span><span class="p">))</span> | ||
|
||
|
||
<span class="k">class</span> <span class="nc">cached_property_with_ttl</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> | ||
<span class="k">class</span> <span class="nc">cached_property_with_ttl</span><span class="p">:</span> | ||
<span class="w"> </span><span class="sd">"""</span> | ||
<span class="sd"> A property that is only computed once per instance and then replaces itself</span> | ||
<span class="sd"> with an ordinary attribute. Setting the ttl to a number expresses how long</span> | ||
|
@@ -251,7 +244,7 @@ <h3 id="searchlabel">Quick search</h3> | |
©2024, CDH @ Princeton University. | ||
|
||
| | ||
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.0.2</a> | ||
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a> | ||
& <a href="https://alabaster.readthedocs.io">Alabaster 1.0.0</a> | ||
|
||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.