<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 2, 2017, at 4:39 AM, Richard Wei &lt;<a href="mailto:rxrwei@gmail.com" class="">rxrwei@gmail.com</a>&gt; wrote:</div><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Question though: how does it work? &nbsp;Say the first np.array call threw a python exception:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><div class=""><div class=""><font face="Menlo" class="">try Python.do {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; let a = np.array([1, 2, 3])</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; let b = np.array([[2], [4]])</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; print(a.dot(b)) // matrix mul with incompatible shapes</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; }</font></div></div></div></div></blockquote></div><div class=""><br class=""></div><div class="">We can definitely make the python glue code notice it, catch it and squirrel it away somewhere, but without compiler hacks we couldn’t make it jump out of the closure. &nbsp;This means that np.array would have to return something, and the calls below it would still execute, or am I missing something?</div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">We make PythonObjects internally nullable (only in the exception-caught state). The second np.array would just return a null PythonObject.&nbsp;</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">To be specific, we define three states in the python overlay:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">- Normal state: PythonObjects are guaranteed to be non-null. Any exception traps.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">- Exception-catching state: PythonObjects are still guaranteed to be non-null. Any exception triggers the exception-caught state.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">- Exception-caught state: PythonObjects are nullable — all python expressions return a null PythonObject.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">The exception-catching state is entered during the execution of Python.do’s body.</div></div></blockquote><br class=""></div><div><br class=""></div><div><div class="">I don’t think that will work well in practice: if you’re intermixing swift and python calls, it would be extremely surprising to see values be computed but produce no value. &nbsp;This seems similar to the ObjC "messaging nil” problem.</div><div class=""><br class=""></div><div class="">That said, I’ve been experimenting with another approach that seems to work well in practice. &nbsp;Due to the language mismatch, a Swift programmer is going to have to decide whether they care about a throwing call or not. &nbsp;As such, I think it makes sense to make this explicit with some kind of syntax - either a postfix operator like ^ or a method like “throwing”. &nbsp;This allows you to write (when we have language sugar) either "a.foo()” or “a.throwing.foo()” if you want to handle the case when foo throws an exception.</div><div class=""><br class=""></div><div class="">This sounds yucky, but actually works pretty well in practice because the “try” warnings (about the absence/excess of try) dovetail really well. &nbsp;Without language support we get something like this:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// import pickle</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;pickle =&nbsp;<span class="" style="color: rgb(79, 129, 135);">Python</span>.<span class="" style="color: rgb(186, 45, 162);">import</span>(<span class="" style="color: rgb(209, 47, 27);">"pickle"</span>)</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// file = open(filename)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">guard</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;file =&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>?&nbsp;<span class="" style="color: rgb(79, 129, 135);">Python</span>.<span class="" style="color: rgb(79, 129, 135);">open</span>.<span class="" style="color: rgb(79, 129, 135);">throwing</span>.<span class="" style="color: rgb(49, 89, 93);">call</span>(args: filename)&nbsp;<span class="" style="color: rgb(186, 45, 162);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>fatalError<span class="" style="color: rgb(0, 0, 0);">(</span><span class="" style="color: rgb(209, 47, 27);">"""</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp; Didn't find data file at&nbsp;<span class="" style="color: rgb(0, 0, 0);">\</span>(<span class="" style="color: rgb(0, 0, 0);">filename</span>)!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp; Update the DataPath at the top of the file.\n</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp; """<span class="" style="color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// blob = file.read()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><div class="" style="margin: 0px; line-height: normal;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;blob = file.<span class="" style="color: rgb(49, 89, 93);">get</span>(member:&nbsp;<span class="" style="color: rgb(209, 47, 27);">"read"</span>).<span class="" style="color: rgb(49, 89, 93);">call</span>(args: [])</div><div class=""><br class=""></div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// a, b, c = pickle.loads(blob)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(186, 45, 162);">&nbsp; let</span>&nbsp;(a,&nbsp;<font color="#ba2da2" class="">b</font>,&nbsp;<font color="#ba2da2" class="">c</font>) = pickle.<span class="" style="color: rgb(49, 89, 93);">get</span>(member:&nbsp;<span class="" style="color: rgb(209, 47, 27);">"loads"</span>).<span class="" style="color: rgb(49, 89, 93);">call</span>(args: blob).<span class="" style="color: rgb(49, 89, 93);">get3Tuple</span>()</div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class="">When we allow sugaring 'x.get(member: “foo”)’ into ‘x.foo’ and allow sugaring x.call(args: a, b, c) into ‘x(a, b,c)’, we’ll get this code:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// import pickle</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;pickle =&nbsp;<span class="" style="color: rgb(79, 129, 135);">Python</span>.<span class="" style="color: rgb(186, 45, 162);">import</span>(<span class="" style="color: rgb(209, 47, 27);">"pickle"</span>)</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// file = open(filename)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">guard</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;file =&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>?&nbsp;<span class="" style="color: rgb(79, 129, 135);">Python</span>.<span class="" style="color: rgb(79, 129, 135);">open</span>.<span class="" style="color: rgb(79, 129, 135);">throwing</span>(filename)&nbsp;<span class="" style="color: rgb(186, 45, 162);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>fatalError<span class="" style="color: rgb(0, 0, 0);">(</span><span class="" style="color: rgb(209, 47, 27);">"""</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;Didn't find data file at&nbsp;<span class="" style="color: rgb(0, 0, 0);">\</span>(<span class="" style="color: rgb(0, 0, 0);">filename</span>)!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;Update the DataPath at the top of the file.\n</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;"""<span class="" style="color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// blob = file.read()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;blob = file.<span class="" style="color: rgb(209, 47, 27);">read()</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// a, b, c = pickle.loads(blob)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(186, 45, 162);">&nbsp; let</span>&nbsp;(a,&nbsp;<font color="#ba2da2" class="">b</font>,&nbsp;<font color="#ba2da2" class="">c</font>) = pickle<span class="" style="color: rgb(209, 47, 27);">loads</span><font color="#31595d" class="">(</font>blob).<span class="" style="color: rgb(49, 89, 93);">get3Tuple</span>()</div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class="">Which is pretty nice. &nbsp; We can talk about making tuple destructuring extensible later. &nbsp;:-)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Here’s the prototype that backs the code above - it is hacky, has known suboptimality, and probably isn’t self contained. &nbsp;I’ll clean this up and write up a proposal for the two bits of sugar above when I have time.</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// This represents the result of a failable operation when working with</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// python values.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">enum</span>&nbsp;PythonError :&nbsp;<span class="" style="color: rgb(112, 61, 170);">Error</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// This represents a null IUO being passed into a PyRef.&nbsp; This should only</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// occur when working with C APIs.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">case</span>&nbsp;nullValue</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// This represents an exception thrown out of a Python API.&nbsp; This can occur</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// on calls.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">case</span>&nbsp;exception(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;: PyRef)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// Reference to a Python value.&nbsp; This is always non-null and always owning of</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// the underlying value.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">final</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">class</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;PyRef :&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">private</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">var</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;state :&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">var</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;borrowedPyObject :&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;state</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">var</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;ownedPyObject :&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;py_INCREF(state)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(ownedThrowing:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!)&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">throws</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">if</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;owned = ownedThrowing {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; state = owned</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; }&nbsp;<span class="" style="color: rgb(186, 45, 162);">else</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">throw</span>&nbsp;PythonError.nullValue</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>public<span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>convenience</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(borrowedThrowing:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!)&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">throws</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.<span class="" style="color: rgb(186, 45, 162);">init</span>(ownedThrowing: borrowedThrowing)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; py_INCREF(state)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>deinit<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; py_DECREF(state)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">convenience</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(owned:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!) {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>!&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.<span class="" style="color: rgb(186, 45, 162);">init</span>(ownedThrowing: owned)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">convenience</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(borrowed:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!) {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>!&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.<span class="" style="color: rgb(186, 45, 162);">init</span>(borrowedThrowing: borrowed)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">convenience</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">?(python:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;) {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.<span class="" style="color: rgb(186, 45, 162);">init</span>(borrowed: python)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;toPythonObject() -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>return<span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>self</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Return a version of this value that throws when an error occurs on its</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// next use.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;throwing :&nbsp;<span class="" style="color: rgb(112, 61, 170);">ThrowingPyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;ThrowingPyRef(<span class="" style="color: rgb(186, 45, 162);">self</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;throwingGet(member:&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(borrowedThrowing: PyObject_GetAttrString(state, member))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(member:&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>! throwingGet(member: member)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;throwingGet(dictMember:&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(borrowedThrowing:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; PyDict_GetItem(state, dictMember.toPythonObject().borrowedPyObject))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(dictMember:&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>! throwingGet(dictMember: dictMember)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Swift subscripts cannot throw yet, so model this as returning an optional</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// reference.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">subscript</span>(throwing idx :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>? {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;item = PyObject_GetItem(<span class="" style="color: rgb(186, 45, 162);">self</span>.state,</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idx.toPythonObject().borrowedPyObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>? PyRef(borrowedThrowing: item)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">subscript</span><span class="" style="color: rgb(0, 0, 0);">(idx :&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">) -&gt;&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>[throwing: idx]!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;throwingGet(tupleItem:&nbsp;<span class="" style="color: rgb(112, 61, 170);">Int</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(borrowedThrowing: PyTuple_GetItem(state, tupleItem))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(tupleItem:&nbsp;<span class="" style="color: rgb(112, 61, 170);">Int</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>! throwingGet(tupleItem: tupleItem)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// Helpers for destructuring tuples</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get2Tuple() -&gt; (<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;(get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">1</span>))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get3Tuple() -&gt; (<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;(get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">1</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">2</span>))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Call self, which must be a Python Callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>public</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;throwingCall(args: [<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>],</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kwargs: [(<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>,<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>)] = [])</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// Make sure state errors are not around.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp; assert(PyErr_Occurred() ==&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">nil</span><span class="" style="color: rgb(0, 0, 0);">,&nbsp;</span>"Python threw an error but wasn't handled"<span class="" style="color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;kwdict = kwargs.isEmpty ?&nbsp;<span class="" style="color: rgb(186, 45, 162);">nil</span>&nbsp;: pyDict(kwargs)</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// Python calls always return a non-null value when successful.&nbsp; If the</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// Python function produces the equivalent of C "void", it returns the None</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// value.&nbsp; A null result of PyObjectCall happens when there is an error,</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// like 'self' not being a Python callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;result =&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(ownedThrowing:</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; PyObject_Call(state, pyTuple(args), kwdict))</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp;&nbsp;</span>// Translate a Python exception into a Swift error if one was thrown.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">if</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;exception = PyErr_Occurred() {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; PyErr_Clear()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">throw</span>&nbsp;PythonError.exception(PyRef(borrowed: exception))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;result</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Call self, which must be a Python Callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>public</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;call(args: [</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">],</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kwargs: [(</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">)] = []) -&gt;&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>! throwingCall(args: args, kwargs: kwargs)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Call self, which must be a Python Callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>public</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;call(args:&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">...,</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kwargs: [(</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">)] = []) -&gt;&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>! throwingCall(args: args, kwargs: kwargs)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// Run the specified closure on the borrowed function guaranteeing the pointer</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// isn't deallocated while the closure runs.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;borrowedMap&lt;T&gt;(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;fn: (<span class="" style="color: rgb(112, 61, 170);">UnsafeMutablePointer</span>&lt;<span class="" style="color: rgb(112, 61, 170);">PyObject</span>&gt;)-&gt;<span class="" style="color: rgb(112, 61, 170);">T</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">T</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;withExtendedLifetime(<span class="" style="color: rgb(186, 45, 162);">self</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;fn(borrowedPyObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// Reference to a Python value.&nbsp; This always throws when handed a null object</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// or when a call produces a Python exception.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">struct</span>&nbsp;ThrowingPyRef {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">private</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;state :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">init</span>(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;value :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; state = value</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(owned:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!)&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">throws</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; state =&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(ownedThrowing: owned)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">(borrowed:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;!)&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">throws</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; state =&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;PyRef(borrowedThrowing: borrowed)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(member:&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;state.throwingGet(member: member)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(dictMember:&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;state.throwingGet(dictMember: dictMember)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Swift subscripts cannot throw yet, so model this as returning an optional</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// reference.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">subscript</span><span class="" style="color: rgb(0, 0, 0);">(idx :&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">) -&gt;&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">? {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;state[throwing: idx]</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get(tupleItem:&nbsp;<span class="" style="color: rgb(112, 61, 170);">Int</span>)&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;state.throwingGet(tupleItem: tupleItem)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get2Tuple()&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt; (<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;(get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">1</span>))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;get3Tuple()&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt; (<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>,&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>) {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;(get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">0</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">1</span>), get(tupleItem:&nbsp;<span class="" style="color: rgb(39, 42, 216);">2</span>))</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Call self, which must be a Python Callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;call(args: [</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">],</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kwargs: [(</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">)] = [])</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;state.throwingCall(args: args, kwargs: kwargs)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>/// Call self, which must be a Python Callable.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;call(args:&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">...,</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kwargs: [(</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">)] = [])</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">throws</span>&nbsp;-&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">try</span>&nbsp;state.throwingCall(args: args, kwargs: kwargs)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><span class="" style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;">}</span></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>ThrowingPyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">init</span><span class="" style="color: rgb(0, 0, 0);">?(python:&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt;) {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.<span class="" style="color: rgb(186, 45, 162);">init</span>(PyRef(python: python)!)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;toPythonObject() -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;state</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;builtinsObject = PyEval_GetBuiltins()!</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);">public<span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>enum<span class="" style="color: rgb(0, 0, 0);">&nbsp;Python {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">static</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;`import`(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;name:&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>) -&gt;&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;PyRef(owned: PyImport_ImportModule(name)!)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">static</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;builtins :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;PyRef(borrowed: builtinsObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// TODO: Make the Python type itself dynamically callable, so that things like</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// "Python.open" naturally resolve to Python.get(member: "open") and all the</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// builtin functions are therefore available naturally and don't have to be</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>// enumerated here.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">static</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;open :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;builtins[<span class="" style="color: rgb(209, 47, 27);">"open"</span>] }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">static</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;repr :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PyRef</span>&nbsp;{&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;builtins[<span class="" style="color: rgb(209, 47, 27);">"repr"</span>] }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">/// Make “print(pyref)" print a pretty form of the tensor.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;</span>CustomStringConvertible<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;description:&nbsp;<span class="" style="color: rgb(112, 61, 170);">String</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;String(python:&nbsp;<span class="" style="color: rgb(186, 45, 162);">self</span>.call(member:&nbsp;<span class="" style="color: rgb(209, 47, 27);">"__str__"</span>))!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);">// Make PyRef's show up nicely in the Xcode Playground results sidebar.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span>PyRef<span class="" style="color: rgb(0, 0, 0);">&nbsp;:&nbsp;</span>CustomPlaygroundQuickLookable<span class="" style="color: rgb(0, 0, 0);">&nbsp;{</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">var</span>&nbsp;customPlaygroundQuickLook:&nbsp;<span class="" style="color: rgb(112, 61, 170);">PlaygroundQuickLook</span>&nbsp;{</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;.text(description)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);">}</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);">//===----------------------------------------------------------------------===//</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);">// Helpers working with PyObjects</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);">//===----------------------------------------------------------------------===//</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);">// Create a Python tuple object with the specified elements.</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;pyTuple(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;vals : [<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>])</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;t = PyTuple_New(vals.count)!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">for</span>&nbsp;(idx, elt)&nbsp;<span class="" style="color: rgb(186, 45, 162);">in</span>&nbsp;vals.enumerated() {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;PyTuple_SetItem(t, idx, elt.toPythonObject().ownedPyObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span>return<span class="" style="color: rgb(0, 0, 0);">&nbsp;t</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;pyTuple(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;vals :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>...)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;pyTuple(vals)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;pyList(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;vals :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>...)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;pyList(vals)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(186, 45, 162);">public</span>&nbsp;<span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;pyList(<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;vals : [<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>])</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;list = PyList_New(vals.count)!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">for</span>&nbsp;(idx, elt)&nbsp;<span class="" style="color: rgb(186, 45, 162);">in</span>&nbsp;vals.enumerated() {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;PyList_SetItem(list, idx, elt.toPythonObject().ownedPyObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;list</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(186, 45, 162);">private</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;pyDict(</span><span class="" style="color: rgb(186, 45, 162);">_</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;elts : [(</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">)])</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;dict = PyDict_New()!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">for</span>&nbsp;(key, val)&nbsp;<span class="" style="color: rgb(186, 45, 162);">in</span>&nbsp;elts {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;PyDict_SetItem(dict, key.toPythonObject().ownedPyObject,</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;val.toPythonObject().ownedPyObject)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;dict</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(186, 45, 162);">public</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="color: rgb(186, 45, 162);">func</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;pySlice(</span><span class="" style="color: rgb(186, 45, 162);">_</span><span class="" style="color: rgb(0, 0, 0);">&nbsp;start:&nbsp;</span>PythonObjectionable<span class="" style="color: rgb(0, 0, 0);">,</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;end:&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>,</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">_</span>&nbsp;step :&nbsp;<span class="" style="color: rgb(112, 61, 170);">PythonObjectionable</span>? =&nbsp;<span class="" style="color: rgb(186, 45, 162);">nil</span>)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="color: rgb(0, 0, 0);">&nbsp;&nbsp;-&gt;&nbsp;</span>UnsafeMutablePointer<span class="" style="color: rgb(0, 0, 0);">&lt;</span>PyObject<span class="" style="color: rgb(0, 0, 0);">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">let</span>&nbsp;stepv = step.flatMap { $0.toPythonObject().ownedPyObject }</div><div class="" style="margin: 0px; line-height: normal; min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp;<span class="" style="color: rgb(186, 45, 162);">return</span>&nbsp;PySlice_New(start.toPythonObject().ownedPyObject,</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;end.toPythonObject().ownedPyObject, stepv)!</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class=""><br class=""></div></div></div></div><br class=""></body></html>