ANN: Dogelog Runtime, Prolog to the Moon (2021)

Chris Angelico rosuav at gmail.com
Sun Sep 19 14:33:39 EDT 2021


On Mon, Sep 20, 2021 at 3:19 AM Mostowski Collapse <janburse at fastmail.fm> wrote:
>
> I am refering to:
>
> Greg Ewing schrieb:
>  > where [w] is a weak reference object. Then you could periodically
>  > scan the trail looking for dead weakref objects and remove the
>  > corresponding [*] node from the list.
>  >
>  > You can also attach callbacks to weakref objects that are triggered
>  > when the referenced object dies. You might be able to make use of
>  > that to remove items from the trail instead of the periodic scanning.
>
> Question to Chris Angelico: If I stay with my
> sweep_trail(), which is the periodically scanning,
> I can use a single linked list.
>
> On the other hand if I would use the trigger
> from Python, I possibly would need a double linked
> list, to remove an element.
>
> Chris Angelico, is there a third option, that I have
> overlooked? Single linked list uses less space
> than double linked list, this why I go with scan.
>

I don't know. I don't understand your code well enough to offer advice
like that, because *your code is too complicated* and not nearly clear
enough.

But however it is that you're doing things, the best way is almost
always to directly refer to objects. Don't fiddle around with creating
your own concept of a doubly-linked list and a set of objects; just
refer directly to the objects. Let Python be Python, don't try to
build your own language on top of it.

ChrisA


More information about the Python-list mailing list