title: Is it good style (or more efficient) to "return early" at the top of a function?
body: <p>Sorry about the confusing title.</p>
  
  <p>I recently started doing this in my project, and am wondering if it's more efficient, or not, and if it's a terrible style to practice.</p>
  
  <p>Here's an example from a Database interface:</p>
  
  <pre><code>def register(self, user, pw):
      """Register user/pw into the database"""
      if self.isStarted():
          raise Exceptions.Started
      hashed = hashlib.sha512(pw).hexdigest()
      self._db_cur.execute('''INSERT INTO PLAYERS (name, password)
                                      values (?, ?)''', [user, hashed])
      self._db.commit()
  </code></pre>
  
  <p>I do it here with raising an exception, but I've done it in other places with a return.</p>
  
  <p>I feel this allows the false-cases to exit the function at the top, instead of continuing down the function, seeing if there is any more code for them to run.</p>
  
  <p>I rarely see this in code I look at: is this a bad practice, or does it not yield any performance like I imagine it to?</p>
  
  <p>
  To help clarify, what I'm used to is:</p>
  
  <pre><code>if (somethingTrue):
      runThis()
      thisToo()
      x = andThis()
      return x
  return None
  </code></pre>
  
  <p>and what I've started to do, and am iffy on:</p>
  
  <pre><code>if (!somethingTrue):
      return None
  runThis()
  thisToo()
  x = andThis()
  return x
  </code></pre>
  
  <p>The latter seems to give the impression (especially in functions longer than 4 lines) that the code isn't part of a conditional, when it's intended that way.  This also makes it look nicer, while adhering to PEP-8, so I'm really in a toss-up about it.</p>
  
  <p>I have a feeling this breaks something horribly sacred.  Is this alright, or sacrilegious?  </p>