Show More
@@ -1,218 +1,227 b'' | |||
|
1 | 1 | ============ |
|
2 | 2 | 7.x Series |
|
3 | 3 | ============ |
|
4 | 4 | |
|
5 | 5 | .. _whatsnew700: |
|
6 | 6 | |
|
7 | 7 | IPython 7.0.0 |
|
8 | 8 | ============= |
|
9 | 9 | |
|
10 | 10 | .. warning:: |
|
11 | 11 | |
|
12 | 12 | IPython 7.0 is currently in Beta. We welcome feedback on API/changes and |
|
13 | 13 | addition/updates to this changelog. |
|
14 | 14 | |
|
15 | 15 | Released .... ...., 2018 |
|
16 | 16 | |
|
17 | 17 | IPython 7 include major features improvement as you can read in the following |
|
18 | 18 | changelog. This is also the second major version of IPython to support only |
|
19 | 19 | Python 3 βΒ starting at Python 3.4. Python 2 is still community supported |
|
20 | 20 | on the bugfix only 5.x branch, but we remind you that Python 2 "end of life" |
|
21 | 21 | is on Jan 1st 2020. |
|
22 | 22 | |
|
23 | 23 | We were able to backport bug fixes to the 5.x branch thanks to our backport bot which |
|
24 | 24 | backported more than `70 Pull-Requests |
|
25 | 25 | <https://github.com/ipython/ipython/pulls?page=3&q=is%3Apr+sort%3Aupdated-desc+author%3Aapp%2Fmeeseeksdev++5.x&utf8=%E2%9C%93>`_, but there are still many PRs that required manually work, and this is an area of the project were you can easily contribute by looking for `PRs still needed backport <https://github.com/ipython/ipython/issues?q=label%3A%22Still+Needs+Manual+Backport%22+is%3Aclosed+sort%3Aupdated-desc>`_ |
|
26 | 26 | |
|
27 | 27 | IPython 6.x branch will likely not see any further release unless critical |
|
28 | 28 | bugs are found. |
|
29 | 29 | |
|
30 | 30 | Make sure you have pip > 9.0 before upgrading. You should be able to update by simply running |
|
31 | 31 | |
|
32 | 32 | .. code:: |
|
33 | 33 | |
|
34 | 34 | pip install ipython --upgrade |
|
35 | 35 | |
|
36 | .. only:: ipydev | |
|
37 | ||
|
38 | To update the beta version, run | |
|
39 | ||
|
40 | .. code:: | |
|
41 | ||
|
42 | pip install ipython --upgrade --pre | |
|
43 | ||
|
44 | ||
|
36 | 45 | Or if you have conda installed: |
|
37 | 46 | |
|
38 | 47 | .. code:: |
|
39 | 48 | |
|
40 | 49 | conda install ipython |
|
41 | 50 | |
|
42 | 51 | |
|
43 | 52 | |
|
44 | 53 | Prompt Toolkit 2.0 |
|
45 | 54 | ------------------ |
|
46 | 55 | |
|
47 | 56 | IPython 7.0+ now uses ``prompt_toolkit 2.0``, if you still need to use earlier |
|
48 | 57 | ``prompt_toolkit`` version you may need to pin IPython to ``<7.0``. |
|
49 | 58 | |
|
50 | 59 | Autowait: Asynchronous REPL |
|
51 | 60 | --------------------------- |
|
52 | 61 | |
|
53 | 62 | Staring with IPython 7.0 and on Python 3.6+, IPython can automatically await |
|
54 | 63 | code at top level, you should not need to access an event loop or runner |
|
55 | 64 | yourself. To know more read the :ref:`autoawait` section of our docs, see |
|
56 | 65 | :ghpull:`11265` or try the following code:: |
|
57 | 66 | |
|
58 | 67 | Python 3.6.0 |
|
59 | 68 | Type 'copyright', 'credits' or 'license' for more information |
|
60 | 69 | IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help. |
|
61 | 70 | |
|
62 | 71 | In [1]: import aiohttp |
|
63 | 72 | ...: result = aiohttp.get('https://api.github.com') |
|
64 | 73 | |
|
65 | 74 | In [2]: response = await result |
|
66 | 75 | <pause for a few 100s ms> |
|
67 | 76 | |
|
68 | 77 | In [3]: await response.json() |
|
69 | 78 | Out[3]: |
|
70 | 79 | {'authorizations_url': 'https://api.github.com/authorizations', |
|
71 | 80 | 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}', |
|
72 | 81 | ... |
|
73 | 82 | } |
|
74 | 83 | |
|
75 | 84 | .. note:: |
|
76 | 85 | |
|
77 | 86 | Async integration is experimental code, behavior may change or be removed |
|
78 | 87 | between Python and IPython versions without warnings. |
|
79 | 88 | |
|
80 | 89 | Integration is by default with `asyncio`, but other libraries can be configured, |
|
81 | 90 | like ``curio`` or ``trio``, to improve concurrency in the REPL:: |
|
82 | 91 | |
|
83 | 92 | In [1]: %autoawait trio |
|
84 | 93 | |
|
85 | 94 | In [2]: import trio |
|
86 | 95 | |
|
87 | 96 | In [3]: async def child(i): |
|
88 | 97 | ...: print(" child %s goes to sleep"%i) |
|
89 | 98 | ...: await trio.sleep(2) |
|
90 | 99 | ...: print(" child %s wakes up"%i) |
|
91 | 100 | |
|
92 | 101 | In [4]: print('parent start') |
|
93 | 102 | ...: async with trio.open_nursery() as n: |
|
94 | 103 | ...: for i in range(3): |
|
95 | 104 | ...: n.spawn(child, i) |
|
96 | 105 | ...: print('parent end') |
|
97 | 106 | parent start |
|
98 | 107 | child 2 goes to sleep |
|
99 | 108 | child 0 goes to sleep |
|
100 | 109 | child 1 goes to sleep |
|
101 | 110 | <about 2 seconds pause> |
|
102 | 111 | child 2 wakes up |
|
103 | 112 | child 1 wakes up |
|
104 | 113 | child 0 wakes up |
|
105 | 114 | parent end |
|
106 | 115 | |
|
107 | 116 | See :ref:`autoawait` for more information. |
|
108 | 117 | |
|
109 | 118 | |
|
110 | 119 | Asynchronous code in a Notebook interface or any other frontend using the |
|
111 | 120 | Jupyter Protocol will need further updates of the IPykernel package. |
|
112 | 121 | |
|
113 | 122 | Non-Asynchronous code |
|
114 | 123 | ~~~~~~~~~~~~~~~~~~~~~ |
|
115 | 124 | |
|
116 | 125 | As the internal API of IPython are now asynchronous, IPython need to run under |
|
117 | 126 | an even loop. In order to allow many workflow, (like using the ``%run`` magic, |
|
118 | 127 | or copy_pasting code that explicitly starts/stop event loop), when top-level code |
|
119 | 128 | is detected as not being asynchronous, IPython code is advanced via a |
|
120 | 129 | pseudo-synchronous runner, and will not may not advance pending tasks. |
|
121 | 130 | |
|
122 | 131 | Change to Nested Embed |
|
123 | 132 | ~~~~~~~~~~~~~~~~~~~~~~ |
|
124 | 133 | |
|
125 | 134 | The introduction of the ability to run async code had some effect on the |
|
126 | 135 | ``IPython.embed()`` API. By default embed will not allow you to run asynchronous |
|
127 | 136 | code unless a event loop is specified. |
|
128 | 137 | |
|
129 | 138 | Effects on Magics |
|
130 | 139 | ~~~~~~~~~~~~~~~~~ |
|
131 | 140 | |
|
132 | 141 | Some magics will not work with Async, and will need updates. Contribution |
|
133 | 142 | welcome. |
|
134 | 143 | |
|
135 | 144 | Expected Future changes |
|
136 | 145 | ~~~~~~~~~~~~~~~~~~~~~~~ |
|
137 | 146 | |
|
138 | 147 | We expect more internal but public IPython function to become ``async``, and |
|
139 | 148 | will likely end up having a persisting event loop while IPython is running. |
|
140 | 149 | |
|
141 | 150 | Thanks |
|
142 | 151 | ~~~~~~ |
|
143 | 152 | |
|
144 | 153 | This took more than a year in the making, and the code was rebased a number of |
|
145 | 154 | time leading to commit authorship that may have been lost in the final |
|
146 | 155 | Pull-Request. Huge thanks to many people for contribution, discussion, code, |
|
147 | 156 | documentation, use-case: dalejung, danielballan, ellisonbg, fperez, gnestor, |
|
148 | 157 | minrk, njsmith, pganssle, tacaswell, takluyver , vidartf ... And many others. |
|
149 | 158 | |
|
150 | 159 | |
|
151 | 160 | Autoreload Improvement |
|
152 | 161 | ---------------------- |
|
153 | 162 | |
|
154 | 163 | The magic ``%autoreload 2`` now captures new methods added to classes. Earlier, only methods existing as of the initial import were being tracked and updated. |
|
155 | 164 | |
|
156 | 165 | This new feature helps dual environment development - Jupyter+IDE - where the code gradually moves from notebook cells to package files, as it gets structured. |
|
157 | 166 | |
|
158 | 167 | **Example**: An instance of the class `MyClass` will be able to access the method `cube()` after it is uncommented and the file `file1.py` saved on disk. |
|
159 | 168 | |
|
160 | 169 | |
|
161 | 170 | ..code:: |
|
162 | 171 | |
|
163 | 172 | # notebook |
|
164 | 173 | |
|
165 | 174 | from mymodule import MyClass |
|
166 | 175 | first = MyClass(5) |
|
167 | 176 | |
|
168 | 177 | .. code:: |
|
169 | 178 | |
|
170 | 179 | # mymodule/file1.py |
|
171 | 180 | |
|
172 | 181 | class MyClass: |
|
173 | 182 | |
|
174 | 183 | def __init__(self, a=10): |
|
175 | 184 | self.a = a |
|
176 | 185 | |
|
177 | 186 | def square(self): |
|
178 | 187 | print('compute square') |
|
179 | 188 | return self.a*self.a |
|
180 | 189 | |
|
181 | 190 | # def cube(self): |
|
182 | 191 | # print('compute cube') |
|
183 | 192 | # return self.a*self.a*self.a |
|
184 | 193 | |
|
185 | 194 | |
|
186 | 195 | |
|
187 | 196 | |
|
188 | 197 | Misc |
|
189 | 198 | ---- |
|
190 | 199 | |
|
191 | 200 | The autoindent feature that was deprecated in 5.x was re-enabled and |
|
192 | 201 | un-deprecated in :ghpull:`11257` |
|
193 | 202 | |
|
194 | 203 | Make ``%run -n -i ...`` work correctly. Earlier, if ``%run`` was passed both arguments, ``-n`` would be silently ignored. See :ghpull:`10308` |
|
195 | 204 | |
|
196 | 205 | |
|
197 | 206 | The ``%%script`` (as well as ``%%bash``, ``ruby``... ) cell magics now raise |
|
198 | 207 | by default if the return code of the given code is non-zero (thus halting |
|
199 | 208 | execution of further cells in a notebook). The behavior can be disable by |
|
200 | 209 | passing the ``--no-raise-error`` flag. |
|
201 | 210 | |
|
202 | 211 | |
|
203 | 212 | Deprecations |
|
204 | 213 | ------------ |
|
205 | 214 | |
|
206 | 215 | A couple of unused function and methods have been deprecated and will be removed |
|
207 | 216 | in future versions: |
|
208 | 217 | |
|
209 | 218 | - ``IPython.utils.io.raw_print_err`` |
|
210 | 219 | - ``IPython.utils.io.raw_print`` |
|
211 | 220 | |
|
212 | 221 | |
|
213 | 222 | Backwards incompatible changes |
|
214 | 223 | ------------------------------ |
|
215 | 224 | |
|
216 | 225 | * The API for transforming input before it is parsed as Python code has been |
|
217 | 226 | completely redesigned, and any custom input transformations will need to be |
|
218 | 227 | rewritten. See :doc:`/config/inputtransforms` for details of the new API. |
General Comments 0
You need to be logged in to leave comments.
Login now