Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.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.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'encoding': 0.05; '"no"': 0.09; 'bits': 0.09; 'tcp/ip': 0.09; 'will,': 0.09; 'worse': 0.09; 'times,': 0.14; 'advice,': 0.16; 'assumptions': 0.16; 'blocking': 0.16; 'enough.': 0.16; 'integers,': 0.16; 'length,': 0.16; 'worse.': 0.16; 'subject:python': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'else,': 0.19; 'seems': 0.21; 'feb': 0.22; 'header :User-Agent:1': 0.23; '"you': 0.24; 'byte': 0.24; 'bytes': 0.24; 'diverse': 0.24; "haven't": 0.24; '(or': 0.24; 'suggested': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'primarily': 0.30; 'streaming': 0.30; 'that.': 0.31; 'subject:skip:i 10': 0.31; 'values.': 0.31; 'probably': 0.32; 'fri,': 0.33; 'raw': 0.33; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'data,': 0.36; 'scheme': 0.36; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'even': 0.60; 'read': 0.60; 'dave': 0.60; 'number,': 0.60; 'length': 0.61; 'numbers': 0.61; 'entire': 0.61; 'making': 0.63; 'such': 0.63; 'our': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; '20,': 0.68; 'reads': 0.68; 'received:74.208': 0.68; 'eight': 0.74; '2015': 0.84; 'angel': 0.91; 'that),': 0.91; 'hand,': 0.93; 'responses': 0.93; 'thereafter': 0.93 Date: Thu, 19 Feb 2015 13:41:48 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: python implementation of a new integer encoding algorithm. References: <515047c1-a20d-430e-a029-1c2d77db2f1a@googlegroups.com> <2a717ffb-d61d-4407-9082-1c17cd7ee573@googlegroups.com> <993f64c3-fc85-48a7-9d02-a4f12ecb33c6@googlegroups.com> <54E62A68.4010603@davea.name> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:ACjeHDTmet2lwSfwm9+VN/d8RMCmdL7tovM28xjcnX5 bcWsCg2wLN0pym6nvYDAs1pggcXwX66Xc+AwHQgZ7GSR2jdKBL gueRY2jT4+YotG7YE8E9w26pQbuxtFYMAkXLshghJkjdK3sxl7 sV+tva0nubAdBBrb+oQN+czdlaL/JvQZvGXOI7zlM0i7PmnWhB KVtpht5dGgWOg2YjnR3Lxjvz9nvc+TIyMvjJM8w37nEJ4tLXrS zHchMNurx5q5ENPnG5Pkd0oUSL90CIpbDjGJhdAgz8Z/xEEfmj /TqslmcSn+/OyM2j6Q/18qqUDzr+aGKIjWPfcAwadxZ+nZWDhB cxPX9dMiKa3Rco+gqQcE= X-UI-Out-Filterresults: notjunk:1; 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424371314 news.xs4all.nl 2913 [2001:888:2000:d::a6]:57979 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85921 On 02/19/2015 01:34 PM, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 5:24 AM, Dave Angel wrote: >> In all my experimenting, I haven't found any values where the 7bit scheme >> does worse. It seems likely that for extremely large integers, it will, but >> if those are to be the intended distribution, the 7bit scheme could be >> replaced by something else, like just encoding a length at the beginning, >> and using raw bytes after that. > > Encoding a length (as varlen) and then using eight bits to the byte > thereafter is worse for small numbers, I only suggested this if it turns out that the distribution is primarily extremely large numbers, large enough that 7bit isn't good enough. As I (and others) have said many times, making it optimal means making some assumptions about the distribution of likely values. > breaks even around 2**56, and > then is better. So unless your numbers are mainly going to be above > 2**56, it's better to just use varlen for the entire number. On the > other hand, if you have to stream this without over-reading (imagine > streaming from a TCP/IP socket; you want to block until you have the > whole number, but not block after that), it may be more efficient to > take the length, and then do a blocking read for the main data, > instead of a large number of single-byte reads. But on the gripping > hand, you can probably just do those one-byte reads and rely on (or > implement) lower-level buffering. > > Ask not the python-list for advice, because they will say both "yes" > and "no" and "maybe"... because they will say all three of "yes", > "no", "maybe", and "you don't need to do that"... erm, AMONG our > responses will be such diverse elements as... > > ChrisA > -- DaveA