A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20160830/68ce54ef/attachment.html below:

<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, 30 Aug 2016 at 10:49 Antoine Pitrou <<a href="mailto:solipsis@pitrou.net">solipsis@pitrou.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, 30 Aug 2016 17:35:35 +0000<br>
Brett Cannon <<a href="mailto:brett@python.org" target="_blank">brett@python.org</a>> wrote:<br>
> ><br>
> > Perhaps a list would work indeed.  Realistically, if there are at most<br>
> > 2-3 users of the field at any given time (and most probably only one or<br>
> > zero), a simple type check (by pointer equality) on each list item may<br>
> > be sufficient.<br>
> ><br>
><br>
> Let's see what Maciej says, but we could standardize on switching the field<br>
> to a list when a conflict of usage is detected so the common case in the<br>
> frame eval function is checking for your own type, and if that fails then<br>
> doing a PyList_CheckExact() and look for your object, otherwise make a list<br>
> and move over to that for everyone to use. A little bit more code, but it's<br>
> simple code and takes care of conflicts only when it calls for it.<br>
<br>
That's a bit obscure and confusing, though (I *think* the weakref module<br>
uses a similar kludge in some place).  If you want to iterate on it you<br>
have to write some bizarre macro to share the loop body between the two<br>
different code-paths (list / non-list), or some equally tedious<br>
function-pointer-based code.<span style="line-height:1.5"> </span></blockquote><div><br></div><div>I don't quite follow where the complexity you're suggesting comes from. The frame evaluation function in Pyjion would just do:</div><div><br></div><div><font face="monospace">  if (co_extra == NULL) {</font></div><div><font face="monospace">  Â  Â  // No one using the field.</font></div><div><font face="monospace">  Â  Â  co_extra = pyjion_cache = PyPyjion_New();</font></div><div><font face="monospace">  }</font></div><div><font face="monospace">  else if (!is_pyjion_object(co_extra)) {</font></div><div><font face="monospace">  Â  // Someone other than us is using the field.</font></div><div><font face="monospace">  Â  if (PyList_CheckExact(co_extra)) {</font></div><div><font face="monospace">  Â  Â  // Field is already a list.</font></div><div><font face="monospace">  Â  Â  ... look for object ...</font></div><div><font face="monospace">  Â  Â  if (ob_found != NULL) {</font></div><div><font face="monospace">  Â  Â  Â  // We're in the list.</font></div><div><font face="monospace">  Â  Â  Â  pyjion_cache = ob_found;</font></div><div><font face="monospace">  Â  Â  }</font></div><div><font face="monospace">  Â  Â  else {</font></div><div><font face="monospace">  Â  Â  Â  // Not in the list, so add ourselves.</font></div><div><font face="monospace">  Â  Â  Â  pyjion_cache = PyPyjion_New();</font></div><div><font face="monospace">  Â  Â  Â  co_extra.append(pyjion_cache);</font></div><div><font face="monospace">  Â  Â  }</font></div><div><font face="monospace">  Â  }</font></div><div><font face="monospace">  Â  else {</font></div><div><font face="monospace">  Â  Â  // Someone else in the field, not a list (yet).</font></div><div><font face="monospace">  Â  Â  other_ob = co_extra;</font></div><div><font face="monospace">  Â  Â  co_extra = PyList_New();</font></div><div><font face="monospace">  Â  Â  co_extra.append(other_ob);</font></div><div><font face="monospace">  Â  Â  pyjion_cache = PyPyjion_New();</font></div><div><font face="monospace">  Â  Â  co_extra.append(pyjion_cache);</font></div><div><font face="monospace">  Â  }</font></div><div><font face="monospace">  }</font></div><div><font face="monospace">  else {</font></div><div><font face="monospace">  Â  // We're in the field.</font></div><div><font face="monospace">  Â  pyjion_cache = co_extra;</font></div><div><font face="monospace">  }</font></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Why not make it always a list?  List objects are reasonably cheap in<br>
memory and access time... (unlike dicts)<br></blockquote><div><br></div><div>Because I would prefer to avoid any form of unnecessary performance overhead for the common case.</div></div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4