Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Hashtable in cython
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter  
View profile  
 More options Oct 1 2012, 1:52 pm
From: Peter <pnau...@dataraker.com>
Date: Mon, 1 Oct 2012 10:52:57 -0700 (PDT)
Local: Mon, Oct 1 2012 1:52 pm
Subject: Hashtable in cython

Is there a hashtable implementation/library available to cython?

I've found the map.pyx, but no hash-based implementations.

Thanks :)

~ Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Bradshaw  
View profile  
 More options Oct 1 2012, 4:39 pm
From: Robert Bradshaw <rober...@gmail.com>
Date: Mon, 1 Oct 2012 13:39:15 -0700
Local: Mon, Oct 1 2012 4:39 pm
Subject: Re: [cython-users] Hashtable in cython

On Mon, Oct 1, 2012 at 10:52 AM, Peter <pnau...@dataraker.com> wrote:
> Is there a hashtable implementation/library available to cython?

> I've found the map.pyx, but no hash-based implementations.

What about Python's builtin dict?

- Robert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nathaniel Smith  
View profile  
 More options Oct 2 2012, 4:23 am
From: Nathaniel Smith <n...@pobox.com>
Date: Tue, 2 Oct 2012 09:17:05 +0100
Local: Tues, Oct 2 2012 4:17 am
Subject: Re: [cython-users] Hashtable in cython

On Mon, Oct 1, 2012 at 6:52 PM, Peter <pnau...@dataraker.com> wrote:
> Is there a hashtable implementation/library available to cython?

> I've found the map.pyx, but no hash-based implementations.

> Thanks :)

If you can't use Python dicts for some reason (e.g. need to hash lots
of small objects without "boxing" them), then khash is popular. Pandas
has cython code to wrap it.

-n


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sturla Molden  
View profile  
 More options Oct 2 2012, 8:17 am
From: Sturla Molden <sturlamol...@yahoo.no>
Date: Tue, 02 Oct 2012 14:17:29 +0200
Local: Tues, Oct 2 2012 8:17 am
Subject: Re: [cython-users] Hashtable in cython
On 01.10.2012 19:52, Peter wrote:

> I've found the map.pyx, but no hash-based implementations.

In C++11, there is an std::unsorted_map which is hash-based (std::map is
a BST). Similarly, std::unsorted_set is hash-based, whereas std::set is
BST based. The interfaces are similar, so just copy the contents of
map.pyx and replace "map" with "unsorted_map" (and ditto for set).

Also note that Pythons builtin dict and set are hash-based, but they can
only store Python objects.

If you need to hash C or C++ objects, use C++11 STL or another C or C++
hash-implementation. You can of course convert a C object to a Python
object, but it comes with a speed penalty.

Sturla


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sturla Molden  
View profile  
 More options Oct 2 2012, 8:22 am
From: Sturla Molden <sturlamol...@yahoo.no>
Date: Tue, 02 Oct 2012 14:22:27 +0200
Local: Tues, Oct 2 2012 8:22 am
Subject: Re: [cython-users] Hashtable in cython
On 02.10.2012 14:17, Sturla Molden wrote:

> In C++11, there is an std::unsorted_map which is hash-based (std::map is
> a BST). Similarly, std::unsorted_set is hash-based, whereas std::set is
> BST based. The interfaces are similar, so just copy the contents of
> map.pyx and replace "map" with "unsorted_map" (and ditto for set).

Sorry, it's called "unordered_map", not "unsorted_map" :)

http://en.wikipedia.org/wiki/Unordered_associative_containers_(C%2B%2B)

Notice how Pythonic the C++ code becomes ;-)

Sturla


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter  
View profile  
 More options Oct 3 2012, 5:25 am
From: Peter <pnau...@dataraker.com>
Date: Wed, 3 Oct 2012 02:25:41 -0700 (PDT)
Local: Wed, Oct 3 2012 5:25 am
Subject: Re: [cython-users] Hashtable in cython

Thanks so much :) This is  exactly what I needed


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jérôme Kieffer  
View profile  
 More options Oct 3 2012, 2:44 pm
From: Jérôme Kieffer <goo...@terre-adelie.org>
Date: Wed, 3 Oct 2012 20:44:06 +0200
Local: Wed, Oct 3 2012 2:44 pm
Subject: Re: [cython-users] Hashtable in cython
On Tue, 02 Oct 2012 14:22:27 +0200

Sturla Molden <sturlamol...@yahoo.no> wrote:
> Notice how Pythonic the C++ code becomes

I am just in a C++11 course and I have the same feeling.
--
Jérôme Kieffer <goo...@terre-adelie.org>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »