@@ -8,8 +8,9 @@ from .NET when targeting Python with Fable.
88
99## Common Types and Objects
1010
11- Some F#/.NET types have counterparts in Python. Fable takes advantage of this
12- to compile to native types that are more performant and reduce code size.
11+ Some F#/.NET types have counterparts in Python. Fable takes advantage of
12+ this to compile to native types that are more performant and reduce code
13+ size. Native types also simplify interop with Python code and libraries.
1314The most important common types are:
1415
1516| F#/.NET Type | Python Type | Notes |
@@ -20,7 +21,7 @@ The most important common types are:
2021| ` Tuple ` | ` tuple ` | Native Python tuple |
2122| ` ResizeArray<T> ` | ` list ` | Native Python list |
2223| ` Dictionary<K,V> ` | ` dict ` | Native Python dict |
23- | ` seq<T> ` / ` IEnumerable ` | iterator | Uses ` __iter__ ` protocol |
24+ | ` seq<T> ` / ` IEnumerable ` | ` Iterable ` | Uses ` __iter__ ` protocol |
2425| ` Array ` | ` FSharpArray ` | Custom wrapper for F# semantics |
2526
2627## .NET Base Class Library
@@ -46,7 +47,7 @@ Most FSharp.Core operators are supported, including formatting with `sprintf`,
4647| F# Type | Python |
4748| ----------------- | -------------------------- |
4849| ` Tuple ` | ` tuple ` |
49- | ` Option<T> ` | erased (see caveats) |
50+ | ` Option<T> ` | erased to ` T \| None ` |
5051| ` string ` | ` str ` |
5152| ` List<T> ` | ` List.fs ` (immutable list) |
5253| ` Map<K,V> ` | ` Map.fs ` (immutable map) |
@@ -235,6 +236,11 @@ let processed =
235236 squared)
236237
237238// Becomes a separate function in Python
239+ (**
240+ We can see that the mapping becomes a separate function in the generated Python code.
241+ *)
242+
243+ (* ** include-python: mapping, processed ***)
238244
239245(**
240246### Numeric Types
@@ -271,6 +277,12 @@ let wrapped: int = maxInt + 1 // Wraps around like .NET
271277// bigint uses Python's native arbitrary-precision int
272278let huge : bigint = 999999999999999999999999999999 I
273279
280+ (**
281+ This generates:
282+ *)
283+
284+ (* ** include-python: small, big, wrapped, huge ***)
285+
274286(**
275287### Computation Expressions
276288
@@ -289,7 +301,8 @@ If your project has `[<EntryPoint>]`, you need:
289301</PropertyGroup >
290302```
291303
292- This ensures absolute imports in generated Python.
304+ This ensures the use of absolute imports in generated Python. Applications
305+ in Python must use absolute imports to run correctly.
293306
294307### Libraries
295308
@@ -307,7 +320,7 @@ Libraries use relative imports by default, which is correct for packages.
307320Fable.Python provides excellent F# support. The main things to watch for are:
308321
309322- Option erasure in edge cases
310- - Multi-line lambda lifting
323+ - Multi-line lambda lifting, will not be anonymous
311324- Some .NET APIs may be missing
312325
313326For most F# code, you can write idiomatic functional code and it will
0 commit comments