Opened 12 years ago

Closed 9 years ago

## #9886 closed defect (duplicate)

# slow coercion from integer mod ring to integer ring, part 2

Reported by: | David Harvey | Owned by: | tbd |
---|---|---|---|

Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |

Component: | performance | Keywords: | |

Cc: | Merged in: | ||

Authors: | Reviewers: | Ralf Stephan | |

Report Upstream: | N/A | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description

Sage 4.5.3, 2.6GHz Opteron, Linux

This is ok:

sage: R = Integers(3^20) sage: u = R(2) sage: timeit("z = u.lift()") 625 loops, best of 3: 351 ns per loop

This is not:

sage: timeit("z = ZZ(u)") 625 loops, best of 3: 37.9 µs per loop

Wow. See also #9885 for a not-quite-as-insane version of this.

### Change History (5)

### comment:1 Changed 12 years ago by

### comment:2 Changed 12 years ago by

I figured out why. Hashing for R is slow, and ZZ._convert_map_hash needs to compute hash(R) to get the appropriate morphism. See #10130 for a patch fixing this.

### comment:3 Changed 9 years ago by

Milestone: | → sage-duplicate/invalid/wontfix |
---|---|

Status: | new → needs_review |

sage-6.2.beta4:

sage: sage: timeit("z = u.lift()") 625 loops, best of 3: 142 ns per loop sage: sage: timeit("z = ZZ(u)") 625 loops, best of 3: 280 ns per loop

### comment:4 Changed 9 years ago by

Reviewers: | → Ralf Stephan |
---|---|

Status: | needs_review → positive_review |

Similar relative result here. (However, my times are 3x slower with 3GHz AMD Phenom, fascinating).

### comment:5 Changed 9 years ago by

Resolution: | → duplicate |
---|---|

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

The patch at #9887 should fix this, but it doesn't. I'm not sure why.