Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What could be more pythonic than PyPy? </p> <p>Look at what I discovered starting at line 284 in ctypes_configure/configure.py:</p> <pre><code> for i in range(0, info['size'] - csize + 1, info['align']): if layout[i:i+csize] == [None] * csize: layout_addfield(layout, i, ctype, '_alignment') break else: raise AssertionError("unenforceable alignment %d" % ( info['align'],)) </code></pre> <p>And here, from line 425 in pypy/annotation/annrpython.py (<a href="http://codespeak.net/pypy/dist/pypy/annotation/annrpython.py" rel="noreferrer">clicky</a>)</p> <pre><code>if cell.is_constant(): return Constant(cell.const) else: for v in known_variables: if self.bindings[v] is cell: return v else: raise CannotSimplify </code></pre> <p>In pypy/annotation/binaryop.py, starting at line 751:</p> <pre><code>def is_((pbc1, pbc2)): thistype = pairtype(SomePBC, SomePBC) s = super(thistype, pair(pbc1, pbc2)).is_() if not s.is_constant(): if not pbc1.can_be_None or not pbc2.can_be_None: for desc in pbc1.descriptions: if desc in pbc2.descriptions: break else: s.const = False # no common desc in the two sets return s </code></pre> <p>A non-one-liner in pypy/annotation/classdef.py, starting at line 176:</p> <pre><code>def add_source_for_attribute(self, attr, source): """Adds information about a constant source for an attribute. """ for cdef in self.getmro(): if attr in cdef.attrs: # the Attribute() exists already for this class (or a parent) attrdef = cdef.attrs[attr] s_prev_value = attrdef.s_value attrdef.add_constant_source(self, source) # we should reflow from all the reader's position, # but as an optimization we try to see if the attribute # has really been generalized if attrdef.s_value != s_prev_value: attrdef.mutated(cdef) # reflow from all read positions return else: # remember the source in self.attr_sources sources = self.attr_sources.setdefault(attr, []) sources.append(source) # register the source in any Attribute found in subclasses, # to restore invariant (III) # NB. add_constant_source() may discover new subdefs but the # right thing will happen to them because self.attr_sources # was already updated if not source.instance_level: for subdef in self.getallsubdefs(): if attr in subdef.attrs: attrdef = subdef.attrs[attr] s_prev_value = attrdef.s_value attrdef.add_constant_source(self, source) if attrdef.s_value != s_prev_value: attrdef.mutated(subdef) # reflow from all read positions </code></pre> <p>Later in the same file, starting at line 307, an example with an illuminating comment:</p> <pre><code>def generalize_attr(self, attr, s_value=None): # if the attribute exists in a superclass, generalize there, # as imposed by invariant (I) for clsdef in self.getmro(): if attr in clsdef.attrs: clsdef._generalize_attr(attr, s_value) break else: self._generalize_attr(attr, s_value) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload