<?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 evil3378 on Medium]]></title>
        <description><![CDATA[Stories by evil3378 on Medium]]></description>
        <link>https://medium.com/@evil3378?source=rss-4463373f9d54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0ZbQfZAdZTJF49Yn.</url>
            <title>Stories by evil3378 on Medium</title>
            <link>https://medium.com/@evil3378?source=rss-4463373f9d54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:05:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@evil3378/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[未來世界 — 王小波]]></title>
            <link>https://medium.com/@evil3378/%E6%9C%AA%E4%BE%86%E4%B8%96%E7%95%8C-%E7%8E%8B%E5%B0%8F%E6%B3%A2-a0a9587a99b5?source=rss-4463373f9d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0a9587a99b5</guid>
            <dc:creator><![CDATA[evil3378]]></dc:creator>
            <pubDate>Thu, 07 Dec 2017 14:17:32 GMT</pubDate>
            <atom:updated>2017-12-07T14:17:32.906Z</atom:updated>
            <content:encoded><![CDATA[<p>參加議而不決的會議,有害身心健康,因此來寫點開心的東西.</p><p>一開始讀王小波,是因為王丹教授介紹的,他提到因為64而入獄前,最終他是到書店剛好買了王小播的黃金時代,就帶著這本書一起進去了.裏面男主角百方設法想藉著敦睦偉大友誼的名義和女生上床, 這本書諷刺荒謬又隱隱帶著某種自由感,大抵就是作者一貫的風格了.</p><p>再來談談王小波吧,以下是維基的說明</p><pre>1952年5月13日出生于北京。<br>1968～1970年云南农场知青。这段经历成为他最著名的作品《黄金时代》的背景。<br>1971～1972年山东牟平插队；后作民办教师。<br>...<br>1977年与当时在《<a href="https://zh.wikipedia.org/wiki/%E5%85%89%E6%98%8E%E6%97%A5%E6%8A%A5">光明日报</a>》做编辑的<a href="https://zh.wikipedia.org/wiki/%E6%9D%8E%E9%8A%80%E6%B2%B3_%28%E7%A4%BE%E6%9C%83%E5%AD%B8%E5%AE%B6%29">李银河</a>相识相恋，后结合。<br>1978～1982年中国人民大学贸易经济系学生。就读于贸易经济商品学专业<br>1991～1992年中国人民大学会计系讲师。<br>...</pre><p>曾下鄉插隊,除了理工背景,對於商,人文學科也有造詣. 個人特別有共鳴的是曾經他也是個程序猿…</p><p><a href="http://91biji.com/social/leon/framebook/notes/note/9174/">http://91biji.com/social/leon/framebook/notes/note/9174/</a></p><pre>闲着没事搞了个发明。原有中文软件是用线扫描方式出汉字。我做了一个用调整字模发生器方法出汉字的系统，自以为很优越，可惜还未找到用户。用此法可以很容易地在西文软件上出中文窗口，还在SPSS上加了几句骂娘的话。</pre><p>最後從程序猿進化成人類了</p><pre>不过现在我对微机已无兴趣，因为发现写小说也可赚到钱。</pre><p><a href="http://www.kanunu8.com/book3/7060/index.html">線上閱讀 ：上下篇</a></p><ul><li><a href="http://www.kanunu8.com/book3/7060/index.html">未来世界 - 王小波 - 小说在线阅读 - 努努书坊</a></li><li><a href="http://www.kanunu8.com/book3/7063/index.html">我自己 - 王小波 - 小说在线阅读 - 努努书坊</a></li></ul><p>還是來談談&lt;未來世界&gt;這本書吧.私心覺得這本書最對胃口,因為他寫的其他&lt;XX時代&gt;有時候反諷的陳述過多, 反而影響個人閱讀的理解,另外 &lt;紅拂夜奔&gt;也有類似的狀況.當中,節奏拿捏比較穩健的就是這篇了.(篇幅也短,適合破碎的時間閱讀)</p><p>本篇提到卡爾維諾&lt;看不見的騎士&gt;,說明一個只存在盔甲卻沒有身體的騎士,每日恪守自訂的規範,也能爭戰殺敵,相形之下顯得一般的騎士彷如空有皮囊的行屍走肉.這樣對立的概念也如此的表現再這部作品中.故事主人翁是個寫作者,只是同樣受到言論自由的箝制,有了以下.</p><pre>我说过，我舅舅很年轻时就得了心脏病。医生对他说：你不能上楼梯，不能呛水，不能抽烟喝酒，不能……，有很多不能；其中当然包括不能做爱。但是大夫又说：只要你不想活了，想干什么都可以。领导对我们说：只要你不出格，写什么都可以。这两句话句式相似，意思却相反，想活和出格的意义完全相悖。所以我舅舅一旦不想活了，就可以干一切事，而我们不出格，就什么都不能写。。</pre><p>這樣概念的極致,讓我想起筒井康隆&lt;最後的吸煙者&gt;(盜夢偵探/穿越時空的少女的作者),對立的最終會是和解嘛？那麼對立的過程似乎顯得枉然.當然自己不會同意這點,卻又難以說明差異, 至少曾經留下什麼吧,就是其中的差異吧.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0a9587a99b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Cyclic Reference]]></title>
            <link>https://medium.com/@evil3378/python-cyclic-reference-%E6%9C%89%E6%84%9F-c654e4ec8b47?source=rss-4463373f9d54------2</link>
            <guid isPermaLink="false">https://medium.com/p/c654e4ec8b47</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[evil3378]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 16:35:54 GMT</pubDate>
            <atom:updated>2017-11-24T01:18:45.674Z</atom:updated>
            <content:encoded><![CDATA[<p>都到職4個月了, 結果事情比較少到底是什麼魔術…<br>為了踏實點只好開始補腦洞</p><p>Problem description：</p><p>使用公司內部的python package讀檔,導致程式直接crash</p><p>Action:</p><p>先用pdb定位crash的代碼位置,發現是公司內部發佈的package,交叉比對發現讀取檔案size過大時,問題即可複現</p><p>再用memory_profiler抓漏,公司使用內部開發的 python package, 解譯內部的文件格式. 但是api返回的並非單純的fd而是自定義的物件,原本3XXMB的檔案直接返回18XMB的物件</p><p>到這邊大概可以結案了,只是繼續看發現開檔完的post process也會造成memory額外一倍的使用. 邊重構邊翻以前的筆記，看可能的狀況</p><p>Extra Note:</p><p>這邊de-coupling做的比較不理想只好,未看先猜cyclic refernece. 類別間彼此引用.翻以前Evernote的筆記, 以下說明引用來自</p><p><a href="https://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python">https://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python</a></p><p>直接來看以下三段代碼:</p><p>定義兩個類別,當中只包含instructor和destructor,其中只會打印訊息</p><p>Version 0.</p><pre>import os  <br>from memory_profiler import profile<br>class foo():<br>    def __init__(self,id):<br>        self.id = id<br>        print &quot;Hello foo&quot;<br>    def __del__(self):<br>        print &quot;Bye foo&quot;<br>class goo():<br>    def __init__(self,id):<br>        self.id = id<br>        print &quot;Hello goo&quot;<br>    def __del__(self):<br>        print &quot;Bye goo&quot;<br>Foo = foo(13)<br>Goo=goo(13)</pre><p>Result:</p><pre>Hello foo<br>Hello goo<br>Bye foo<br>Bye goo</pre><p>非常直覺,在產生物件後, script執行完成python GC類別所定義的destructor進行清理,因此單純顯示instructor和destructor的打印訊息</p><p>稍微調整,若是設計兩個類別彼此引用,goo建構時產生foo的物件,再將本身傳入給foo作做建構. 當程式結束後,沒有呼叫destructor.</p><p>Version1:</p><pre>from memory_profiler import profile<br>class foo():<br>    def __init__(self,id,parent):<br>        self.id = id<br>        self.parent = parent<br>        print &quot;Hello foo&quot;<br>    def __del__(self):<br>        print &quot;Bye foo&quot;<br>class goo():<br>    def __init__(self,id):<br>        self.id = id<br>        self.f = foo(id,self)<br>        print &quot;Hello goo&quot;<br>    def __del__(self):<br>        print &quot;Bye goo&quot;<br>Goo=goo(13)</pre><p>Result:</p><pre>Hello foo<br>Hello goo</pre><p>解決方式: 顯式地 宣告此為weak reference ,讓GC在traverse heap的引用時,可以認出這段cyclic reference可以進行回收(事後去查python 2.7的文件,其實官方的文件和對應實作已經很豐富了,大概很多人踩過坑吧)</p><p>Version2:</p><pre>import os  <br>from memory_profiler import profile<br>import weakref<br>class foo():<br>    def __init__(self,id,parent):<br>        self.id = id<br>        <em>self.parent = weakref.ref(parent)</em><br>        print &quot;Hello foo&quot;<br>    def __del__(self):<br>        print &quot;Bye foo&quot;<br>class goo():<br>    def __init__(self,id):<br>        self.id = id<br>        self.f = foo(id,self)<br>        print &quot;Hello goo&quot;<br>    def __del__(self):<br>        print &quot;Bye goo&quot;<br>Goo=goo(13)</pre><p>Result:</p><pre>Hello foo<br>Hello goo<br>Bye foo<br>Bye goo</pre><p>額外參考：</p><p><a href="https://docs.python.org/2/library/weakref.html">https://docs.python.org/2/library/weakref.html</a></p><p><a href="http://puretech.iteye.com/blog/2008663">http://puretech.iteye.com/blog/2008663</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c654e4ec8b47" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>