33Narwhals is primarily aimed at library maintainers rather than end users. As such,
44we need to take stability and backwards compatibility extra-seriously. Our policy is:
55
6- - If you write code using ` import narwhals.stable.v1 as nw ` , then we promise to
6+ - If you write code using ` narwhals.stable.v1 ` or ` import narwhals.stable.v2 ` , then we promise to
77 never change or remove any public function you're using.
88- If we need to make a backwards-incompatible change, it will be pushed into
9- ` narwhals.stable.v2 ` , leaving ` narwhals.stable.v1 ` unaffected.
10- - We will maintain ` narwhals.stable.v1 ` indefinitely, even as ` narwhals.stable.v2 ` and other
11- stable APIs come out. For example, Narwhals version 1.0.0 will offer
12- ` narwhals.stable.v1 ` , whereas Narwhals 2.0.0 will offer both ` narwhals.stable.v1 ` and
13- ` narwhals.stable.v2 ` .
9+ the main ` narwhals ` namespace (and eventually ` narwhals.stable.v3 ` ),
10+ leaving ` narwhals.stable.v1 ` and ` narwhals.stable.v2 ` unaffected.
11+ - We will maintain ` narwhals.stable.v1 ` and ` narwhals.stable.v2 ` indefinitely,
12+ even as ` narwhals.stable.v3 ` and other stable APIs come out. For example,
13+ Narwhals version 1.0.0 offers ` narwhals.stable.v1 ` , whereas Narwhals 2.0.0 offers
14+ both ` narwhals.stable.v1 ` and ` narwhals.stable.v2 ` .
1415
1516Like this, we enable different packages to be on different Narwhals stable APIs, and for
1617end-users to use all of them in the same project without conflicts nor
@@ -49,8 +50,8 @@ it. That is to say, if you write your code like this:
4950
5051=== "from/to_native"
5152 ```python
52- import narwhals.stable.v1 as nw
53- from narwhals.typing import IntoFrameT
53+ import narwhals.stable.v2 as nw
54+ from narwhals.stable.v2. typing import IntoFrameT
5455
5556
5657 def func(df: IntoFrameT) -> IntoFrameT:
@@ -59,8 +60,8 @@ it. That is to say, if you write your code like this:
5960
6061=== "@narwhalify "
6162 ```python
62- import narwhals.stable.v1 as nw
63- from narwhals.typing import FrameT
63+ import narwhals.stable.v2 as nw
64+ from narwhals.stable.v2. typing import FrameT
6465
6566
6667 @nw.narwhalify
@@ -73,18 +74,19 @@ after they have renamed their method.
7374
7475Concretely, we would do the following:
7576
76- - ` narwhals.stable.v1 ` : you can keep using ` Expr.cum_sum `
77- - ` narwhals.stable.v2 ` : you can only use ` Expr.cumulative_sum ` , ` Expr.cum_sum ` will have been removed
77+ - ` narwhals.stable.v2 ` : you can keep using ` Expr.cum_sum `
78+ - ` narwhals.stable.v3 ` : you can only use ` Expr.cumulative_sum ` , ` Expr.cum_sum ` will have been removed
7879- ` narwhals ` : you can only use ` Expr.cumulative_sum ` , ` Expr.cum_sum ` will have been removed
7980
80- So, although Narwhals' main API (and ` narwhals.stable.v2 ` ) will have introduced a breaking change,
81- users of ` narwhals.stable.v1 ` will have their code unaffected.
81+ So, although Narwhals' main API (and ` narwhals.stable.v3 ` ) will have introduced a breaking change,
82+ users of ` narwhals.stable.v2 ` will have their code unaffected.
8283
8384### Exceptions
8485
8586Are we really promising perfect backwards compatibility in all cases, without exceptions? Not quite.
8687There are some exceptions, which we'll now list. But we'll never intentionally break your code.
87- Anything currently in ` narwhals.stable.v1 ` will not be changed or removed in future Narwhals versions.
88+ Anything currently in ` narwhals.stable.v1 ` or ` narwhals.stable.v2 ` will not be changed or removed
89+ in future Narwhals versions.
8890
8991Here are exceptions to our backwards compatibility policy:
9092
@@ -100,16 +102,24 @@ Here are exceptions to our backwards compatibility policy:
100102In general, decision are driven by use-cases, and we conduct a search of public GitHub repositories
101103before making any change.
102104
103-
104- ### ` import narwhals as nw ` or ` import narwhals.stable.v1 as nw ` ?
105+ ### ` import narwhals as nw ` , ` import narwhals.stable.v2 as nw ` , or ` import narwhals.stable.v1 as nw ` ?
105106
106107Which should you use? In general we recommend:
107108
108109- When prototyping, use ` import narwhals as nw ` , so you can iterate quickly.
109110- Once you're happy with what you've got and want to release something production-ready and stable,
110- then switch out your ` import narwhals as nw ` usage for ` import narwhals.stable.v1 as nw ` .
111+ then switch out your ` import narwhals as nw ` usage for ` import narwhals.stable.v2 as nw ` .
112+ - If you're starting a new project, use either the main Narwhals namespace or ` narwhals.stable.v2 ` .
113+ - If your project is already using ` narwhals.stable.v1 ` , and you don't need any of the newer Narwhals
114+ features, there's probably no need to switch to ` narwhals.stable.v2 ` , as that would require you to
115+ raise the minimum version of Narwhals you support. If you'd like to use ` narwhals.stable.v2 ` , make
116+ sure to require at least ` narwhals>=2.0 ` .
117+
118+ ## ` main ` vs ` stable.v2 ` differences
111119
112- ## ` main ` vs ` stable.v1 `
120+ So far, nothing, everything non-unstable from the main namespace should be available in ` narwhals.stable.v2 ` .
121+
122+ ## ` main ` vs ` stable.v1 ` differences
113123
114124- Since Narwhals 1.49:
115125
@@ -133,6 +143,9 @@ Which should you use? In general we recommend:
133143
134144- Since Narwhals 1.29.0, ` LazyFrame.gather_every ` has been deprecated from the main namespace.
135145
146+ - Since Narwhals 1.25.0, ` native_namespace ` is generally deprecated across the API. Please
147+ use ` backend ` instead.
148+
136149- Since Narwhals 1.24.1, an empty or all-null object-dtype pandas Series is inferred to
137150 be of dtype ` String ` . Previously, it would have been inferred as ` Object ` .
138151
0 commit comments