Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103620
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Sven R. Kunze" <srkunze@mail.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Bug in Python? |
| Date | Sun, 28 Feb 2016 11:08:55 +0100 |
| Lines | 28 |
| Message-ID | <mailman.5.1456654139.9760.python-list@python.org> (permalink) |
| References | <56D0CCE9.2000301@mail.de> <CACL+1asoZSWcuB2fX3qLNinu8Eo1aEeEd0o+c88=3dKbbJY-eA@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de I7EBDfE3Kto0CJ7A9+rjYQL+fe100JVZGp4xLuT9XgaQ== |
| Return-Path | <srkunze@mail.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'cpython': 0.05; 'method.': 0.05; 'called.': 0.09; 'dict': 0.09; 'modifies': 0.09; 'overridden': 0.09; 'python': 0.10; '2016': 0.16; '_heapq': 0.16; 'earlier.': 0.16; 'expands': 0.16; 'heap': 0.16; 'macro': 0.16; 'mylist': 0.16; 'presume': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:name:python list': 0.16; "type's": 0.16; 'wrote:': 0.16; 'basically': 0.18; 'skip:` 10': 0.18; 'skip:` 20': 0.18; 'extension': 0.20; 'to:2**1': 0.21; 'latter': 0.22; 'code.': 0.23; 'seems': 0.23; 'feb': 0.23; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'fri,': 0.27; 'module.': 0.27; 'function': 0.28; 'mind,': 0.29; 'array': 0.29; 'normally': 0.30; 'somebody': 0.30; 'operations': 0.31; 'operations.': 0.33; 'this?': 0.34; 'received:10.0': 0.34; 'best,': 0.35; 'could': 0.35; 'skip:* 20': 0.35; 'sometimes': 0.35; 'but': 0.36; 'list,': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'method': 0.37; 'thought': 0.37; 'things': 0.38; 'loss': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'back': 0.62; 'more': 0.63; 'here:': 0.63; 'due': 0.65; 'between': 0.65; 'binding': 0.66; 'course.': 0.67; '26,': 0.72; 'carried': 0.76; 'forth': 0.79; 'penalty': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1456654138; bh=iPQlS50ZtxpDDt2k4tzwz62OUcR+ByzPeeOXPEBmw2U=; h=Subject:To:References:From:Date:In-Reply-To:From; b=fqIjVcpYauY3h4fI4g04JHBBUBZpVADaILt6ksCsQsk2bYHAbPEFnouxeRaJ/GALG eU7sWOTpLJdYw3m7+nf6o2Patik828wYNgrZUo4elLcCHcAThtC6Cs/DDWaVpZK9H/ VjCjPlAgb9khCvtiudtPC5KAfW01orEW02Smn5Lo= |
| In-Reply-To | <CACL+1asoZSWcuB2fX3qLNinu8Eo1aEeEd0o+c88=3dKbbJY-eA@mail.gmail.com> |
| X-purgate | clean |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate-type | clean |
| X-purgate-Ad | Categorized by eleven eXpurgate (R) http://www.eleven.de |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate | clean |
| X-purgate-size | 1455 |
| X-purgate-ID | 154282::1456654138-000009F3-819A7D86/10/3071143950 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| 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> |
| Xref | csiph.com comp.lang.python:103620 |
Show key headers only | View raw
On 27.02.2016 00:07, eryk sun wrote: > On Fri, Feb 26, 2016 at 4:08 PM, Sven R. Kunze <srkunze@mail.de> wrote: >> Python sometimes seems not to hop back and forth between C and Python code. >> Can somebody explain this? > Normally a C extension would call PySequence_SetItem, which would call > the type's sq_ass_item, which for MyList is slot_sq_ass_item. The > latter function bridges the CPython and Python sides by binding and > calling the overridden __setitem__ method. However, the _heapq > extension module uses `PyList_SET_ITEM(heap, 0, lastelt)`. This macro > expands to `((PyListObject *)(heap))->ob_item[0] = lastelt`. This > directly modifies the internal ob_item array of the list, so the > overridden __setitem__ method is never called. I presume it was > implemented like this with performance in mind, but I don't know > whether or not that justifies the loss of generality. I think this is true and it explains the huge performance penalty of the current RemovalHeap and XHeap implementation as it basically uses Python only (results here: http://bit.ly/1KU7CyW). Shoot! I could have seen this earlier. I thought the performance penalty was due to calling __setitem__ and dict operations. But having all heap operations carried out in Python slows things down considerably of course. Let's see if I can manage to create a more efficient mark-and-sweep approach which uses the C module. Best, Sven
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Bug in Python? "Sven R. Kunze" <srkunze@mail.de> - 2016-02-28 11:08 +0100
csiph-web