Data-structure for multiway associativity in Python
Dan Stromberg
drsalists at gmail.com
Sat Jan 27 13:49:24 EST 2018
It's possible, but not common, to do association lists in Python.
They're pretty inefficient in just about any language.
I'm not totally clear on what you need, but it might be a good thing
to do a list of sets - if you're looking for an in-memory solution.
On Sat, Jan 27, 2018 at 10:33 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
> On Sat, 27 Jan 2018 10:01:47 -0800 (PST), qrious <mittra at juno.com>
> declaimed the following:
>
>>
>>
>>I need a data structure and a corresponding (hopefully fast) mechanism associated with it to do the following. While I am looking for the concept first, my preference for implementation of this will be in Python.
>>
>>[c1, c2,..., cn] is a list of strings (for my own implementation, but could be any other type for the generic problem). There will be many hundreds, if not thousands, of such lists with no shared member.
>>
>>The method getAssocList(e) will return lists of the lists for which e is an element.
>>
>>Here a hash may be a way to go, but need help in figuring it out. Also, can there be a faster and more memory efficient solution other than hashes?
>
>
> Don't know about speed or memory but...
>
> SQLite3 (*n* is primary key/auto increment; _n_ is foreign key)
>
> LoL(*ID*, description)
>
> anL(*ID*, _LoL_ID_, cx)
>
> select LoL.description, anL.cx from LoL
> inner join anL on anL.LoL_ID = LoL.ID
> where anL.cx like "%e%"
>
> {note: using like and wildcards means e is anywhere in the cx field;
> otherwise just use
>
> anL.cx = "e"
> }
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list