<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashley Wans on Medium]]></title>
        <description><![CDATA[Stories by Ashley Wans on Medium]]></description>
        <link>https://medium.com/@wansac?source=rss-952be767752f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Oc-hyxvS11cQh2zM9zq7WA.jpeg</url>
            <title>Stories by Ashley Wans on Medium</title>
            <link>https://medium.com/@wansac?source=rss-952be767752f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:09:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wansac/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Git User’s Guide to Branching in Subversion]]></title>
            <link>https://medium.com/@wansac/a-git-users-guide-to-branching-in-subversion-beda7f299653?source=rss-952be767752f------2</link>
            <guid isPermaLink="false">https://medium.com/p/beda7f299653</guid>
            <category><![CDATA[source-control]]></category>
            <category><![CDATA[subversion]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Ashley Wans]]></dc:creator>
            <pubDate>Thu, 24 Sep 2020 01:42:33 GMT</pubDate>
            <atom:updated>2020-09-24T01:42:33.024Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZjBR691LCdsTzmKLS4bV2w.png" /><figcaption>A Google Trends comparison of version control search terms on September 13, 2020. <a href="https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=git,svn,Mercurial">See it now.</a></figcaption></figure><p>By the time I started my career, Git had already become the staple source control option in the software world. I worked with Git exclusively for nearly eight years before encountering a Subversion repo in the wild in my professional life.</p><p>Branching in Subversion isn’t as seamless as it is in Git. This isn’t a surprise given that svn is, in general, not as full-featured as Git. Subversion does support branching, however, and this article will walk you through the basics of creating and working on a branch using svn. This tutorial assumes that you are already comfortable with <a href="https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow">the basic concept of branching</a> and have an svn repository currently checked out on your system.</p><h4>What’s a branch in Subversion?</h4><p>In Subversion, branches are directories. Your repository structure might look like this:</p><pre>project/<br>   branches/<br>       FEATURE-1/<br>       FEATURE-2/<br>       HOT-FIX-1/<br>       DEV_BRANCH/<br>       ...</pre><pre>    trunk/<br>        src/<br>        tests/<br>        ...</pre><p>The “trunk” folder is analogous to the master branch in Git. When developers are ready to merge their branches, they merge them into trunk.</p><p>To a Git user, this structure looks very odd. Do you work in the branches directory? What if the code in FEATURE-1 has dependencies in trunk? How do you run it in that case?</p><p>This is where the <a href="http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.switch.html">svn switch</a> command comes in. When you are ready to work on FEATURE-1, you will run svn switch on the files under development in trunk/, allowing the branch code to run in place. I discuss the switch command more later on. First, let’s learn how to create a branch.</p><h4>Creating a branch</h4><p>The <a href="http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.copy.html">copy </a>command allows us to create a branch directory.</p><pre>svn copy -m &quot;Creating branch for FEATURE-3&quot; http://subversion.mycompany.com/path/to/trunk/folder http://subversion.mycompany.com/path/to/branches/FEATURE-3</pre><p>This is going to copy all the contents in /path/to/trunk/folder into a new folder in the branches directory. Your project should now have this basic structure this:</p><pre>project/<br>   branches/<br>       FEATURE-1/<br>       FEATURE-2/ <br>       FEATURE-3/<br>           file_1.c<br>           file_1.h<br>           ...<br>       HOT-FIX-1/<br>       DEV_BRANCH/<br>       ...</pre><pre>trunk/<br>        src/<br>           folder/<br>              file_1.c<br>              file_1.h<br>              ...<br>           tests/<br>           ...</pre><p>Copies of the files in folder/ are now in a new directory called FEATURE-3. The original files in folder/ remain where they started in trunk/src/folder.</p><p>The copy command will show up as a commit containing the new directory and copied files in the Subversion history. The string following the “-m” is the commit message, just as it would be following an svn commit command.</p><p>In contrast to Git, with Subversion it matters where in your project you branch. In this example, we copied just the contents of folder/ into FEATURE-3/, which limits us to developing on just those files on this branch. Should we need to update a file in the tests/ folder, we would need to create a new branch. Conversely, if we copied all of the contents of src/ into FEATURE-3/, this may be many more files than we need and make for an ugly code review and merge.</p><h4>Developing on a branch</h4><p>Now that FEATURE-3/ exists, you can switch trunk/src/folder/ to your branch, allowing you to work on the branch code inside trunk/ where all of its dependencies live.</p><p>Run the switch command from the folder you copied in the original svn copy command above:</p><pre>cd trunk/src/folder/ &amp;&amp; svn switch http://subversion.mycompany.com/path/to/branches/FEATURE-3</pre><p>Note that the branch URL here is the same as the URL used in the original copy command as well.</p><p>trunk/src/folder/ is now “switched” to your branch. Running the <a href="http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.info.html">svn info</a> command will confirm this:</p><pre>ashley@computer:~/folder$ svn info</pre><pre>Path: .</pre><pre>Working Copy Root Path: /home/ashley/project</pre><pre>URL: http://subversion.mycompany.com/path/to/branches/FEATURE-3</pre><pre>Relative URL: ^/path/to/branches/FEATURE-3</pre><pre>Repository Root: http://subversion.mycompany.com/project</pre><pre>Repository UUID: 1234-5678-91011</pre><pre>Revision: 11223344</pre><pre>Node Kind: directory</pre><pre>Schedule: normal</pre><pre>Last Changed Author: awans</pre><pre>Last Changed Rev: 11223344</pre><pre>Last Changed Date: 2020-09-14 08:28:21 -0700 (Mon, 14 Sep 2020)</pre><p>Now when you make changes on trunk/src/folder/file_1.c, you’re actually making changes on your branch. Committing these changes will commit them on your branch, rather than straight to trunk.</p><p>To switch back to trunk, run the same switch command with the main trunk URL:</p><pre>svn switch http://subversion.mycompany.com/path/to/trunk/folder</pre><h4>Merging to trunk</h4><p>We’ll now fast-forward several days, to when your work on FEATURE-3 is complete. You’ve been through code review and received various accolades for your brilliant work. All process hurdles have been cleared, and it’s now time to merge your branch to trunk!</p><p>First, merge trunk to your branch just as you would merge master to your branch in Git. Note that if trunk has changed significantly since you branched, you may get merge conflicts. Resolving merge conflicts is outside the scope of this guide, but the command line feedback svn gives you on merge conflicts is relatively straight-forward:</p><pre>...<br>Summary of conflicts:<br>  Tree conflicts: 1<br>Tree conflict on &#39;path/to/trunk/folder/&#39;<br>   &gt; local dir edit, incoming dir delete or move upon switch<br>Select: (r) mark resolved, (p) postpone, (q) quit resolution, (h) help: p<br>Summary of conflicts:<br>  Tree conflicts: 1</pre><p>To merge trunk into your branch, make sure you are “switched” onto your branch and run:</p><pre>svn merge http://subversion.mycompany.com/path/to/trunk/folder</pre><p>Note that you can append “ — dry-run” to the command above. This is a way to test the merge before actually merging so you can see in advance if any conflicts will occur. I don’t find this particularly useful, as I’ll need to resolve conflicts anyway whether or not I knew about them beforehand, but some folks do find this to be a handy sanity-check tool.</p><p>After trunk has been merged into your branch, commit the changes incorporated by the merge:</p><pre>svn commit -m &quot;Merged latest changes on trunk to FEATURE-3&quot;</pre><p>Now switch your folder to trunk:</p><pre>svn switch http://subversion.mycompany.com/path/to/trunk/folder</pre><p>Merge your branch into trunk, using the dry-run flag first if you wish:</p><pre>svn merge http://subversion.mycompany.com/path/to/branches/FEATURE-3</pre><p>And commit the change:</p><pre>svn commit -m &quot;Merged FEATURE-3 into trunk&quot;</pre><p>Your feature branch has now been merged into trunk!</p><h4>After the merge</h4><p>Depending on how active your repository is and how many branches exist, you may wish to delete your feature branch after it has been merged. Note that this will delete it from branches/, but will not delete it from the Subversion history.</p><p>The <a href="http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.delete.html">svn delete</a> command is straight-forward:</p><pre>svn delete http://subversion.mycompany.com/path/to/branches/FEATURE-3 -m &quot;Deleting FEATURE-3 branch&quot;</pre><p>This isn’t required; you may leave the branch in branches/ indefinitely if you wish.</p><h4>Final thoughts</h4><p>Branching in Subversion feels clunky and counterintuitive if you’re a Git user, but it is fully supported. It is <a href="http://svnbook.red-bean.com/en/1.7/svn.branchmerge.using.html">well-documented </a>should these instructions fail to clarify the process.</p><p>Happy branching!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=beda7f299653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Python/C API: A Brief Introduction]]></title>
            <link>https://medium.com/@wansac/the-python-c-api-a-brief-introduction-7926ea0ef488?source=rss-952be767752f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7926ea0ef488</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cpython]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Ashley Wans]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 00:51:06 GMT</pubDate>
            <atom:updated>2020-09-14T00:51:06.821Z</atom:updated>
            <content:encoded><![CDATA[<p>The Python/C API: A Brief Introduction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6AKTOxqNlmVgrfVrZm3Aw.png" /><figcaption>CPython’s implementation of Py_Initialize in <a href="https://github.com/python/cpython/blob/94bfdee25db31941b187591ae5ae9bf3ed431090/Python/pylifecycle.c#L1189">pylifecycle.c</a></figcaption></figure><p>The Python/C API brings together two of my two favorite things: Python and C.</p><h4>What is it?</h4><p>The <a href="https://docs.python.org/3/c-api/index.html">Python/C API</a> allows C programmers to embed Python directly into C code by exposing aspects of <a href="https://github.com/python/cpython">CPython</a> internals. It provides direct access to the Python interpreter from C, acting as a bridge between the two languages.</p><h4>An example</h4><p>This C code calls Python’s <a href="https://docs.python.org/3/library/platform.html">platform.system()</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd0747eea702c58450f69b1821113f63/href">https://medium.com/media/cd0747eea702c58450f69b1821113f63/href</a></iframe><p>On my system, this code prints out:</p><pre>Platform name is Darwin</pre><h4>Building</h4><p>I built the code above on my Mac by running:</p><pre>gcc -o example example.c -I&lt;Python include directory&gt; /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib</pre><p>I configured, built, and installed CPython on my system, but this isn’t necessary. You can also <a href="https://www.python.org/downloads/release/python-380/">download a Python installer</a>, let it perform a default install, and then locate libpython and Python.h on your system.</p><p>On my Windows machine, the Python 3.8 installer placed Python.h in:</p><pre>C:\Users\&lt;user&gt;\AppData\Local\Programs\Python\Python38\include </pre><p>And python38.lib is in:</p><pre>C:\Users\&lt;user&gt;\AppData\Local\Programs\Python\Python38\libs</pre><h4>But why embed Python in C?</h4><p>Why reinvent wheels that already roll well in Python? When execution at the speed of pure C isn’t necessary (and perhaps rapid development time is), embedding Python is an extremely effective tool for leveraging functionality that already exists in Python. My first foray into working with the Python/C API was driven by exactly this situation: I had a great deal of well-tested Python code that I did not want to duplicate in my C application.</p><p>Python internals are also fascinating and worth getting to know in their own right.</p><h4>Performance</h4><p>As an interpreted language, Python is generally slower than C. In the system.platform() example above, the calls into the Python/C API still have to be interpreted, meaning that the performance of these calls will be similar to the performance of calling system.platform() from Python. If Python isn’t a good choice for your application, it’s unlikely that the C API will change that (and in fact, the extra assignments required may make it an even worse choice).</p><p>The same C API allows programmers to create Python extensions in C which do not need to be interpreted because they are compiled straight to C. This results in highly performant code, but this is different than the example of embedded Python that I share above.</p><h4>Backwards compatibility</h4><p>The C code above will not compile if the user’s system only has Python 2.7 installed.</p><p>The C API is necessarily updated when the rest of Python is updated. As a result, backwards compatibility isn’t always maintained between versions. This is something to consider when choosing to use existing Python code or to recreate the same functionality in C.</p><h4>Multi-threading</h4><p>Multi-threading using the C API is possible, but it can be complicated by Python’s <a href="https://wiki.python.org/moin/GlobalInterpreterLock">Global Interpreter Lock</a>.</p><p>The code to manage the GIL is straight-forward enough:</p><pre>PyGILState_STATE gstate;</pre><pre>...</pre><pre>void example_function(void)<br>{</pre><pre>    PyGILState_Ensure();</pre><pre>    ...</pre><pre>    PyGILState_Release(gstate);<br>}</pre><p>In practice, all of my multi-threaded C applications that call Python have required a bit of debugging before I fully understood how the GIL was functioning in context.</p><h4>Reference Counting</h4><p>Lines 35–37 in example.c provide an example of the <a href="https://docs.python.org/3/extending/extending.html#reference-counts">reference counting API:</a></p><pre>// Decrement reference counts for objects we are</pre><pre>// done using to allow garbage collection to dispose of them</pre><pre>Py_XDECREF(system_function);</pre><pre>Py_XDECREF(system_obj);</pre><pre>Py_XDECREF(str);</pre><p>The <a href="https://docs.python.org/3/extending/extending.html#refcounts">docs</a> explain:</p><blockquote>Since Python makes heavy use of malloc() and free(), it needs a strategy to avoid memory leaks as well as the use of freed memory. The chosen method is called <em>reference counting</em>. The principle is simple: every object contains a counter, which is incremented when a reference to the object is stored somewhere, and which is decremented when a reference to it is deleted. When the counter reaches zero, the last reference to the object has been deleted and the object is freed.</blockquote><p>The <a href="https://docs.python.org/3/extending/extending.html">documentation</a> on extending and embedding Python provides a thorough description of reference counting.</p><h4>Ultimately</h4><p>When execution speed isn’t at issue, the Python/C API is an extremely useful tool for leveraging existing functionality in Python.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7926ea0ef488" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>