Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'tends': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:library': 0.09; 'library': 0.13; 'method.': 0.15; 'python?': 0.15; 'ctypes.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'pdf:': 0.16; 'structures,': 0.16; 'url:cosc': 0.16; 'wrap': 0.18; 'seems': 0.20; 'header:In- Reply-To:1': 0.22; 'stefan': 0.24; 'subject:data': 0.25; 'work,': 0.28; 'described': 0.28; 'url:)': 0.29; 'url:src': 0.30; 'usually': 0.31; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'test': 0.34; 'header:X-Complaints-To:1': 0.34; 'calling': 0.34; 'matter,': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'class.': 0.37; 'url:ac': 0.37; 'but': 0.37; 'using': 0.37; 'data': 0.38; 'url:org': 0.39; 'received:de': 0.39; 'subject:from': 0.39; 'recommended': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'url:nz': 0.67; '2-3': 0.73; 'url:c': 0.74; 'url:research': 0.91; 'available:': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Porting the 2-3 heap data-structure library from C to Python Date: Wed, 07 Mar 2012 15:52:27 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: fw-snc-frn5-de01.fw.telefonica.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1331131962 news.xs4all.nl 6853 [2001:888:2000:d::a6]:45048 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21320 Alec Taylor, 07.03.2012 15:25: > I am planning to port the 2-3 heap data-structure as described by > Professor Tadao Takaoka in Theory of 2-3 Heaps published in 1999 and > available in PDF: > http://www.cosc.canterbury.ac.nz/tad.takaoka/2-3heaps.pdf > > The source-code used has been made available: > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.h > http://www.cosc.canterbury.ac.nz/research/RG/alg/ttheap.c > > I plan on wrapping it in a class. > > This tutorial I used to just test out calling C within Python > (http://richizo.wordpress.com/2009/01/25/calling-c-functions-inside-python/) > and it seems to work, but this might not be the recommended method. > > Any best practices for how best to wrap the 2-3 heap data-structure > from C to Python? For data structures, where performance tends to matter, it's usually best to start with Cython right away, instead of using ctypes. http://cython.org/ Here's a tutorial for wrapping a C library with it: http://docs.cython.org/src/tutorial/clibraries.html Stefan