Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:code': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; '7:58': 0.16; 'docstrings': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject: \n ': 0.16; 'subject:possible': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'module': 0.19; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'adds': 0.24; 'received:comcast.net': 0.24; 'subject: .': 0.24; 'source': 0.25; 'first,': 0.26; 'nearly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'code': 0.31; 'are,': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'depends': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'simply': 0.61; 'offer': 0.62; 'valuable': 0.63; 'sam': 0.68; 'therefore': 0.72; 'protect': 0.79; 'compiling': 0.84; 'gone.': 0.84; 'subject:source': 0.84; 'secrets': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Is it possible to protect python source code by compiling it to .pyc or .pyo? Date: Thu, 16 Jan 2014 20:07:04 -0500 References: <7bf45fc1-e1c4-44f2-812c-e11ffa2c8ef3@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <7bf45fc1-e1c4-44f2-812c-e11ffa2c8ef3@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389920837 news.xs4all.nl 2856 [2001:888:2000:d::a6]:40903 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64125 On 1/16/14 7:58 PM, Sam wrote: > I would like to protect my python source code. It need not be foolproof as long as it adds inconvenience to pirates. > > Is it possible to protect python source code by compiling it to .pyc or .pyo? Does .pyo offer better protection? > First, .pyc and .pyo are nearly identical: they are bytecode. The only difference is that .pyo has been "optimized", which in this case simply means that the docstrings and asserts are gone. It is not difficult to see what a Python program does by looking at the bytecode, and the standard library includes the dis module for disassembling it. How to protect your code depends an awful lot on what kinds of secrets are in the code, and how valuable those secrets are, and therefore how hard someone will work to get at them. -- Ned Batchelder, http://nedbatchelder.com