Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87931

Re: Newbie looking for elegant solution

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'elements.': 0.07; 'energy,': 0.09; 'integers': 0.09; 'spec': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; '2.7': 0.14; '105,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'numpy': 0.16; 'only?': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'skip:l 30': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.30; '25,': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'installing': 0.36; 'processed': 0.36; 'list': 0.37; 'same.': 0.38; 'pm,': 0.38; 'does': 0.39; 'read': 0.60; 'become': 0.64; 'effectively': 0.66; 'latest': 0.67; 'mar': 0.68; '2015': 0.84; 'issues:': 0.84; "paul's": 0.84; 'subject:looking': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Hm8ASAAQTFM+XT9ZRVbWC6ZGZv52T0zW/FcqChBN02w=; b=qSylTLXECBKyPTPaItYOlwOZeDLXtIuLTx3PgPhFsajF6XZMmVO+lqCSDLxNxRqMIP g84OaBGlDJaf8CiyPjCh+9niaRFQfMVmV/NN7+KK8E5zlfi4oHkyBwVCXVW5vPHv4zbA H7Hedory236n3xk0Ln7xLnSZV4eESFByWGVMtMblrLwKqn43am9lIoiY/KMRqBnuvKQX Vqp4cJUrKfqydm62s3K7yUWVGKxD9/vpIBGLjux1Ei8Cjy/zOGQhvV1Q9Yk4Lg0zf+mo ScG5Y7qY6QXxIqe6MMpA6WP/PbdYImtnsPogF0145yVMhfk5SnaUqGpJI/9ad+swYIIN vvSA==
MIME-Version 1.0
X-Received by 10.50.79.161 with SMTP id k1mr27199008igx.14.1427259905813; Tue, 24 Mar 2015 22:05:05 -0700 (PDT)
In-Reply-To <0e0fbfec-0265-490b-9300-d2c1f2bb4391@googlegroups.com>
References <bc226abc-2860-47d9-9d75-8e1ad1cae097@googlegroups.com> <874mp97mf9.fsf@jester.gateway.sonic.net> <mailman.129.1427257197.10327.python-list@python.org> <0e0fbfec-0265-490b-9300-d2c1f2bb4391@googlegroups.com>
Date Wed, 25 Mar 2015 16:05:05 +1100
Subject Re: Newbie looking for elegant solution
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.131.1427259914.10327.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427259914 news.xs4all.nl 2834 [2001:888:2000:d::a6]:60066
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87931

Show key headers only | View raw


On Wed, Mar 25, 2015 at 3:46 PM,  <kai.peters@gmail.com> wrote:
> Now I have just read the latest spec and speed/memory may become issues:
>
> 1 bit images of a size of 1024 x 1280 need to be processed this way, so
> 1310720 list elements. Also needs to be 2.7 only.
>
> Any recommendations?

2.7 only? Then my solution won't work (I just tried to port it, and
integers don't have to_bytes). Paul's solution works. Here's an
alternative:

>>> import numpy
>>> list(numpy.packbits(numpy.array(l),-1))
[177, 105, 117]

Of course, this does mean installing numpy. It is crushing the nut
with the triphammer - an absurd extravagance of energy, but the nut is
effectively crushed all the same.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Newbie looking for elegant solution otaksoftspamtrap@gmail.com - 2015-03-24 20:13 -0700
  Re: Newbie looking for elegant solution Chris Angelico <rosuav@gmail.com> - 2015-03-25 14:28 +1100
    Re: Newbie looking for elegant solution otaksoftspamtrap@gmail.com - 2015-03-24 20:31 -0700
  Re: Newbie looking for elegant solution Paul Rubin <no.email@nospam.invalid> - 2015-03-24 21:04 -0700
    Re: Newbie looking for elegant solution kai.peters@gmail.com - 2015-03-24 21:19 -0700
    Re: Newbie looking for elegant solution Chris Angelico <rosuav@gmail.com> - 2015-03-25 15:19 +1100
      Re: Newbie looking for elegant solution kai.peters@gmail.com - 2015-03-24 21:46 -0700
        Re: Newbie looking for elegant solution Chris Angelico <rosuav@gmail.com> - 2015-03-25 16:05 +1100
        Re: Newbie looking for elegant solution Ben Finney <ben+python@benfinney.id.au> - 2015-03-25 16:28 +1100
        Re: Newbie looking for elegant solution Paul Rubin <no.email@nospam.invalid> - 2015-03-24 22:52 -0700
          Re: Newbie looking for elegant solution Rustom Mody <rustompmody@gmail.com> - 2015-03-24 23:32 -0700
  Re: Newbie looking for elegant solution Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-25 16:24 +1100
  Re: Newbie looking for elegant solution Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> - 2015-03-25 06:05 +0000
  Re: Newbie looking for elegant solution Travis Griggs <travisgriggs@gmail.com> - 2015-03-25 11:49 -0700
  Re: Newbie looking for elegant solution kai.peters@gmail.com - 2015-03-25 16:14 -0700
    Re: Newbie looking for elegant solution Paul Rubin <no.email@nospam.invalid> - 2015-03-25 16:30 -0700
    Re: Newbie looking for elegant solution Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-03-26 00:34 +0100
  Re: Newbie looking for elegant solution kai.peters@gmail.com - 2015-03-25 17:38 -0700
    Re: Newbie looking for elegant solution Paul Rubin <no.email@nospam.invalid> - 2015-03-25 18:09 -0700
      Re: Newbie looking for elegant solution kai.peters@gmail.com - 2015-03-25 18:29 -0700
        Re: Newbie looking for elegant solution Paul Rubin <no.email@nospam.invalid> - 2015-03-25 19:53 -0700

csiph-web