Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer.__index__() currently goes via a python long #440

Closed
sagetrac-dmharvey mannequin opened this issue Aug 18, 2007 · 4 comments
Closed

Integer.__index__() currently goes via a python long #440

sagetrac-dmharvey mannequin opened this issue Aug 18, 2007 · 4 comments

Comments

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Aug 18, 2007

Currently Integer.__index__() goes via a python long. In most cases the result should be just a python int, and it should be much faster to go directly there.

Probably the best way to implement this is to first call mpz_size(x.value) to check the size in words; if the size is one, then construct a python int directly; otherwise go to a long.

Even better might be to write another version of mpz_get_pylong which can produce a python int when that's feasible, or a long if it's not.

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/440

@sagetrac-dmharvey
Copy link
Mannequin Author

sagetrac-dmharvey mannequin commented Aug 18, 2007

comment:1

oops I forgot to mention the above comment is for sage 2.8

@sagetrac-dmharvey
Copy link
Mannequin Author

sagetrac-dmharvey mannequin commented Aug 18, 2007

comment:2

Here's a profile, on sage.math, sage 2.8.1:

sage: L = [None] * 10
sage: index = Integer(5)
sage: timeit x = L[index]
1000000 loops, best of 3: 690 ns per loop
sage: timeit x = L[index]
1000000 loops, best of 3: 691 ns per loop

Let's see if we can do better than that...

@sagetrac-dmharvey
Copy link
Mannequin Author

sagetrac-dmharvey mannequin commented Aug 18, 2007

comment:3

I'm about to attach a patch for this, here is the new profile:

sage: L = [None] * 10
sage: index = Integer(5)
sage: timeit x = L[index]
1000000 loops, best of 3: 331 ns per loop

@sagetrac-dmharvey
Copy link
Mannequin Author

sagetrac-dmharvey mannequin commented Aug 18, 2007

Attachment: trac-440.hg.gz

adds new mpz_get_pyintlong function, change some calls in Integer class to use this function

@williamstein williamstein added this to the sage-2.8.2 milestone Aug 18, 2007
vbraun pushed a commit to vbraun/sage that referenced this issue Dec 9, 2023
    
Bumps [actions/github-script](https://github.com/actions/github-script)
from 6.4.0 to 7.0.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/actions/github-
script/releases">actions/github-script's releases</a>.</em></p>
<blockquote>
<h2>v7.0.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Avoid setting <code>baseUrl</code> to undefined when input is not
provided by <a
href="https://github.com/joshmgross"><code>@​joshmgross</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/439">actions/github-script#439</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-
script/compare/v7.0.0...v7.0.1">https://github.com/actions/github-
script/compare/v7.0.0...v7.0.1</a></p>
<h2>v7.0.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Add base-url option by <a
href="https://github.com/robandpdx"><code>@​robandpdx</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/429">actions/github-script#429</a></li>
<li>Expose async-function argument type by <a
href="https://github.com/viktorlott"><code>@​viktorlott</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/402">actions/github-script#402</a>, see for details <a
href="https://github.com/actions/github-script#use-scripts-with-jsdoc-
support">https://github.com/actions/github-script#use-scripts-with-
jsdoc-support</a></li>
<li>Update dependencies and use Node 20 by <a
href="https://github.com/joshmgross"><code>@​joshmgross</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/425">actions/github-script#425</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/navarroaxel"><code>@​navarroaxel</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-
script/pull/285">actions/github-script#285</a></li>
<li><a href="https://github.com/robandpdx"><code>@​robandpdx</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-
script/pull/429">actions/github-script#429</a></li>
<li><a
href="https://github.com/viktorlott"><code>@​viktorlott</code></a> made
their first contribution in <a
href="https://redirect.github.com/actions/github-
script/pull/402">actions/github-script#402</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-
script/compare/v6.4.1...v7.0.0">https://github.com/actions/github-
script/compare/v6.4.1...v7.0.0</a></p>
<h2>v6.4.1</h2>
<h2>What's Changed</h2>
<ul>
<li>Add <code>@​octokit/plugin-request-log</code>, to produce debug
output for requests by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/358">actions/github-script#358</a></li>
<li>fix input handling by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/357">actions/github-script#357</a></li>
<li>Remove unused dependencies by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/356">actions/github-script#356</a></li>
<li>Default debug to current runner debug state by <a
href="https://github.com/mjpieters"><code>@​mjpieters</code></a> in <a
href="https://redirect.github.com/actions/github-
script/pull/363">actions/github-script#363</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/mjpieters"><code>@​mjpieters</code></a>
made their first contribution in <a
href="https://redirect.github.com/actions/github-
script/pull/358">actions/github-script#358</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/actions/github-
script/compare/v6.4.0...v6.4.1">https://github.com/actions/github-
script/compare/v6.4.0...v6.4.1</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="actions/github-script@60a0d83039c
74a4aee543508d2ffcb1c3799cdea"><code>60a0d83</code></a> Merge pull
request <a href="https://redirect.github.com/actions/github-
script/issues/440">sagemath#440</a> from actions/joshmgross/v7.0.1</li>
<li><a href="actions/github-script@b7fb2001b41
0c9390cbe9e2c7d5cab7eefb7b29c"><code>b7fb200</code></a> Update version
to 7.0.1</li>
<li><a href="actions/github-script@12e22ed06b6
cf302663f90a925045516e24c8bad"><code>12e22ed</code></a> Merge pull
request <a href="https://redirect.github.com/actions/github-
script/issues/439">sagemath#439</a> from actions/joshmgross/avoid-setting-base-
url</li>
<li><a href="actions/github-script@d319f8f5b55
ea40916b869b2ca9ae2f059c60abf"><code>d319f8f</code></a> Avoid setting
<code>baseUrl</code> to undefined when input is not provided</li>
<li><a href="actions/github-script@e69ef5462fd
455e02edcaf4dd7708eda96b9eda0"><code>e69ef54</code></a> Merge pull
request <a href="https://redirect.github.com/actions/github-
script/issues/425">sagemath#425</a> from actions/joshmgross/node-20</li>
<li><a href="actions/github-script@ee0914b839b
704083a749f8c77a73a9270674a32"><code>ee0914b</code></a> Update
licenses</li>
<li><a href="actions/github-script@d6fc56f33b0
17d55917d045da1a94efa2120f039"><code>d6fc56f</code></a> Use
<code>@types/node</code> for Node 20</li>
<li><a href="actions/github-script@384d6cf5814
52587d1e31f553c97ab165427124a"><code>384d6cf</code></a> Fix quotations
in tests</li>
<li><a href="actions/github-script@84724927e3e
992f17768c17f57a47a85ea2a5160"><code>8472492</code></a> Only validate
GraphQL <code>previews</code></li>
<li><a href="actions/github-script@84903f51828
821af5d03d3884c6ba699a2d44d6e"><code>84903f5</code></a> Remove
<code>node-fetch</code> from type</li>
<li>Additional commits viewable in <a
href="https://github.com/actions/github-
script/compare/v6.4.0...v7.0.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-
badges.githubapp.com/badges/compatibility_score?dependency-
name=actions/github-script&package-manager=github_actions&previous-
version=6.4.0&new-
version=7.0.1)](https://docs.github.com/en/github/managing-security-
vulnerabilities/about-dependabot-security-updates#about-compatibility-
scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>
    
URL: sagemath#36739
Reported by: dependabot[bot]
Reviewer(s): Kwankyu Lee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant