Skip to content

Use deepcopy inside ConstantColoringAlgorithm if necessary #257

Closed

Description

@gdalle

ConstantColoringAlgorithm is peculiar because it builds the coloring result right away, and then returns the same object over and over again. If people use it from several threads it can lead to race conditions, but only for result types that contain scratch memory (aka acyclic coloring or linear system). This is not possible at the moment but we should remain aware of it if we extend ConstantColoringAlgorithm to the symmetric case

Activity

  1. nsajko commented on Sep 10, 2025

    @nsajko
    Contributor

    deepcopy is basically internals. It's public API, although perhaps that was a mistake, as it is very easy to misuse, and I don't think there's a generically correct way to use it. In any case, see this warning present in the doc string of deepcopy in development versions of Julia:

    It is better to avoid this function in favor of custom copy methods or use-case-specific copying functions. deepcopy is slow and can easily copy too many objects, or generate an object that violates invariants, since it does not respect abstraction boundaries.

    Apart from the above warnings, AFAIK the compiler can't optimize deepcopy calls well, although I may be wrong.

    TLDR: I suggest not using deepcopy.

  2. amontoison commented on Nov 1, 2025

    @amontoison
    Collaborator

    @gdalle Can we close this issue now?

  3. gdalle commented on Nov 1, 2025

    @gdalle
    MemberAuthor

    Yes this is fixed by #263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions