<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>clients on Launchpad Blog</title>
    <link>https://blog.launchpad.net/tags/clients/</link>
    <description>News and updates from the Launchpad team</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 14 Jul 2010 13:30:04 +0000</lastBuildDate>
    <atom:link href="https://blog.launchpad.net/feed/tags/clients/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Three tips for faster launchpadlib api clients</title>
      <link>https://blog.launchpad.net/api/three-tips-for-faster-launchpadlib-api-clients/</link>
      <pubDate>Wed, 14 Jul 2010 13:30:04 +0000</pubDate>
      <dc:creator>Martin Pool</dc:creator>
      <guid isPermaLink="false">https://blog.launchpad.net/?p=1626</guid>
      <description>&lt;p&gt;Three tips from &lt;a href=&#34;http://launchpad.net/~leonardr&#34;&gt;Leonard&amp;rsquo;s&lt;/a&gt; lightning talk in Prague about writing faster &lt;a href=&#34;https://help.launchpad.net/API/launchpadlib#preview&#34;&gt;Launchpadlib&lt;/a&gt; API clients:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Use the latest launchpadlib.&lt;/strong&gt; It gets faster from one release to the next.  (The versions in the current Ubuntu release should be fine; otherwise run from the &lt;a href=&#34;https://code.edge.launchpad.net/~lazr-developers/launchpadlib/trunk&#34;&gt;branch&lt;/a&gt; or the latest &lt;a href=&#34;https://launchpad.net/launchpadlib/+download&#34;&gt;tarball&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Profile:&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;    import httplib2
    httplib2.debuglevel = 1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;will show each http request and response, so that you can see what&amp;rsquo;s taking time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Fetch objects only once:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t do this:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;    if bug.person is not None:
        print bug.person.name
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;instead&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;    p = bug.person
    if p is not None:
        print p.name
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the first case, the client may fetch the Person object twice.  (We may fix this in future.)&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
