Manifold (was RE: Unpacking a python list in C?)

Ken Seehof kseehof at neuralintegrator.com
Fri May 3 21:52:21 EDT 2002


Michael Hudson wrote:
> Glad to hear it!  I should really write some docs for the extending
> and embedding manual...

Many would be grateful.  BTW, I have written a code generator (wizard)
for extending:

http://www.neuralintegrator.com/downloads/extwizard

Unfortunately, it's a windows MS Visual C++ plug-in wizard.  Potentially
it could mutate into a multi-platform extension IDE with a wxPython GUI.

> > I look forward to putting this stuff on SourceForge to get more
> > feedback, when I get some free time.
> >
> > In case you're wondering, "manifold" is a new kind of list.
>
> So why's it called manifold then?  To me manifold means "topological
> space locally isomorphic to Euclidean space"...

All the other good names are already taken :-).  Manifold also means
"many", which sort of connotes a list.  But the mathematical definition
that you describe is actually the reason I picked it.

In a funny kind of way, my manifold type is analogous to a topological
manifold.  It is implemented as a two-dimensional quadruply linked list
without edges (i.e. a discrete torus).  When programming in C++ I have
often used a one-dimensional version (a doubly linked list with no head or
tail that forms a ring).  The ring structure is better than a conventional
doubly linked list because adding or removing at the beginning and end are
not special cases.  The manifold data structure could be extended to three
or more dimensions but I haven't thought of any good reason for doing so.
The theoretical ability to use additional dimensions in a manner analogous
to a multi-dimensional discrete manifold enhances my choice of name.

I am open to the possibility of renaming the whole thing if someone gives
me a better name, or if this data structure has a name (I haven't ever
seen it before).  Of course, once I make an official SourceForge release,
the names won't change.

> > - safe deletion during iteration
> > - O(constant) fast __contains__ (in) operator
> > - global explicit object removal (fast)
> > - python thread safe
> >
> > Basically it solves the problem of explicit removal of an object from
> > all "lists" of which it is a member, especially in situations where
> > object removal of any kind would normally be hazardous.  I've been using
> > it for a couple weeks, and it seems stable.  The sequence initialization
> > that I posted is one of a few recent additions for completeness.
>
> Not sure I really understand... can you show me how it's used?
>
> Cheers,
> M.

Sure.  I just now put it on my web site.  I still haven't gotten around
to learning sourceforge (lazy again...) and anyway I need to make sure
it's portable first (unfortunately, it's a Windows project right now).

  http://www.neuralintegrator.com/downloads/manifold

This is released under the python style open source license.

Consider this an unofficial pre-release for windows.  Anything can
change, and I won't promise backwards compatibility issues until I
release a proper sourceforge version.  Having made that disclaimer, I
don't think the current syntax and semantics will change much.  I wasn't
planning to release it quite yet, but it beats trying to explain it.

I a haven't written a multi-threaded stress test yet, but I am currently
using it in a somewhat complex GUI that involved queues, trees, nested
loops and user driven global object removal and it feels stable to me.

Thanks to Michael Hudson for the manifold constructor improvement.  I
welcome any feedback people have (but I reserve the right to ignore any
feedback for any reason).

- Ken






More information about the Python-list mailing list