forked from numba/numba
-
Notifications
You must be signed in to change notification settings - Fork 1
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
initial stab at docs for typed-list #7
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _deprecation: | ||
|
||
=================== | ||
Deprecation Notices | ||
=================== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Contents in this file are referenced from the sphinx-generated docs. | ||
# "magictoken" is used for markers as beginning and ending of example text. | ||
|
||
|
||
def ex_inferred_list_jit(): | ||
# magictoken.ex_inferred_list_jit.begin | ||
from numba import njit | ||
from numba.typed import List | ||
|
||
@njit | ||
def foo(): | ||
# Instantiate a typed-list | ||
l = List() | ||
# Append a value to it, this will set the type to int32/int64 (depending on platform) | ||
l.append(42) | ||
# The usual list operations, getitem, pop and length are supported | ||
print(l[0]) # 42 | ||
l[0] = 23 | ||
print(l[0]) # 23 | ||
print(len(l)) # 1 | ||
l.pop() | ||
print(len(l)) # 0 | ||
return l | ||
|
||
mylist = foo() | ||
|
||
# magictoken.ex_inferred_list_jit.end | ||
|
||
|
||
def ex_inferred_list(): | ||
# magictoken.ex_inferred_list.begin | ||
from numba import njit | ||
from numba.typed import List | ||
|
||
@njit | ||
def foo(mylist): | ||
for i in range(10, 20): | ||
mylist.append() | ||
return mylist | ||
|
||
# Instantiate a typed-list, outside of a jit context | ||
l = List() | ||
# Append a value to it, this will set the type to int32/int64 (depending on platform) | ||
l.append(42) | ||
# The usual list operations, getitem, pop and length are supported | ||
print(l[0]) # 42 | ||
l[0] = 23 | ||
print(l[0]) # 23 | ||
print(len(l)) # 1 | ||
l.pop() | ||
print(len(l)) # 0 | ||
|
||
# And you can use the typed-list as an argument for a jit compiled function | ||
|
||
l = foo(l) | ||
print(len(l)) # 10 | ||
|
||
# magictoken.ex_inferred_list.end | ||
|
||
|
||
def ex_nested_list(): | ||
# magictoken.ex_nested_list.begin | ||
from numba.typed import List | ||
|
||
# typed-lists can be nested in typed-lists | ||
mylist = List() | ||
for i in range(10): | ||
l = List() | ||
for i in range(10): | ||
l.append(i) | ||
mylist.append(l) | ||
# mylist is now a list of 10 lists, each containing 10 integers | ||
print(mylist) | ||
|
||
# magictoken.ex_nested_list.end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps reference the documentation on reflection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for the that is almost exactly below, I am hoping this relative reference should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I can do, is reference the deprecation schedule.