#31658 closed enhancement (fixed)

Slight speed-up in copy method

Reported by: Michael Jung Owned by:
Priority: major Milestone: sage-9.4
Component: manifolds Keywords: copy, tensorfields, sections
Cc: Eric Gourgoulhon, Travis Scrimshaw, Matthias Köppe Merged in:
Authors: Michael Jung Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: ffa35d9 (Commits, GitHub, GitLab) Commit: ffa35d9380ca0a717c1b90ed8b9e7fbe878f7dea
Dependencies: Stopgaps:

Status badges

Description (last modified by Michael Jung)

We have for the copy method of tensor fields and sections currently the following code:

        resu = self._new_instance()
        for dom, rst in self._restrictions.items():
            resu._restrictions[dom] = rst.copy()
        resu.set_name(name=name, latex_name=latex_name)
        resu._is_zero = self._is_zero
        return resu

where resu.set_name(name=name, latex_name=latex_name) loops over all restrictions again. These two loops can be reduced to just one loop by passing name and latex_name to the restriction's copy-method.

Change History (18)

comment:1 Changed 20 months ago by Michael Jung

Branch: u/gh-mjungmath/copy_tensorfield

comment:2 Changed 20 months ago by Michael Jung

Branch: u/gh-mjungmath/copy_tensorfield
Description: modified (diff)

comment:3 Changed 20 months ago by Michael Jung

Description: modified (diff)
Status: newneeds_review

comment:4 Changed 20 months ago by Michael Jung

Branch: u/gh-mjungmath/copy_tensorfield

comment:5 Changed 20 months ago by Travis Scrimshaw

Commit: a56ee0d39b3ab4bfbd673d8d216502daab3fbc7e
Reviewers: Travis Scrimshaw

Green bot => you can set a positive review.


New commits:

a56ee0dsomething

comment:6 Changed 20 months ago by Travis Scrimshaw

Although your commit message also leaves something to be desired too.

comment:7 Changed 20 months ago by Michael Jung

Oh yes. I actually wanted to amend the commit before pushing. :D

comment:8 Changed 20 months ago by Travis Scrimshaw

Green bot, but please amend the commit before setting to a positive review.

comment:9 Changed 20 months ago by git

Commit: a56ee0d39b3ab4bfbd673d8d216502daab3fbc7e27c2fcb3f19491570555506cbeca6aefbe3a40d2

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

27c2fcbTrac #31658: pass names to branched copy method

comment:10 Changed 20 months ago by Michael Jung

Status: needs_reviewpositive_review

There we go. Thank you for the review Travis!

comment:11 Changed 20 months ago by git

Commit: 27c2fcb3f19491570555506cbeca6aefbe3a40d2b0240cc16c1c08e5d7b3cf3c226d5b33151ec86e
Status: positive_reviewneeds_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

b0240ccTrac #31658: same change for copy_from

comment:12 Changed 20 months ago by Michael Jung

Just noticed, the same change can be applied to copy_from making it faster, too. Sorry Travis!

comment:13 Changed 20 months ago by Travis Scrimshaw

Status: needs_reviewpositive_review

comment:14 Changed 20 months ago by git

Commit: b0240cc16c1c08e5d7b3cf3c226d5b33151ec86effa35d9380ca0a717c1b90ed8b9e7fbe878f7dea
Status: positive_reviewneeds_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. This was a forced push. New commits:

ffa35d9Trac #31658: same change for copy_from

comment:15 Changed 20 months ago by Michael Jung

Typo in code caused pyflakes error.

comment:16 Changed 20 months ago by Travis Scrimshaw

Status: needs_reviewpositive_review

comment:17 Changed 20 months ago by Matthias Köppe

Milestone: sage-9.3sage-9.4

comment:18 Changed 18 months ago by Volker Braun

Branch: u/gh-mjungmath/copy_tensorfieldffa35d9380ca0a717c1b90ed8b9e7fbe878f7dea
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.