paleolimbot opened a new pull request, #458:
URL: https://github.com/apache/arrow-nanoarrow/pull/458

   This PR unifies how types are printed, which was different among the 
`Array`, `Scalar`, `ArrayStream`, and `Schema`. These now all use the same 
function such that type information is communicated in a consistent way for all 
user-facing classes.
   
   The general approach is to print all possible information on the first line. 
Most types have descriptions like `int32`, so this is a good fit and there's no 
need for multiple lines. This makes a list of schemas (e.g., `schema.fields`) 
have a nice repr, too. The Schema repr additionally prints out metadata if 
present (this is skipped by the other classes).
   
   Some examples:
   
   ```python
   import nanoarrow as na
   
   # Schema with no parameters
   na.int32()
   #> <Schema> int32
   
   # Type parameters are already part of the schema's to_string
   na.fixed_size_binary(123)
   #> <Schema> fixed_size_binary(123)
   
   # non-nullable schema
   na.int32(nullable=False)
   #> <Schema> non-nullable int32
   
   # named schema
   na.Schema(na.int32(), name="some_col")
   #> <Schema> 'some_col': int32
   
   # ordered dictionary
   na.dictionary(na.int32(), na.string(), True)
   #> <Schema> ordered dictionary(int32)<string>
   
   # Schema with metadata
   na.Schema(na.int32(), metadata={"some key": "some value"})
   #> <Schema> int32
   #> - metadata: {b'some key': b'some value'}
   
   # fields are already a part of the schema's to_string
   struct = na.struct({"some col": na.int32(), "some other col": na.string()})
   struct
   #> <Schema> struct<some col: int32, some other col: string>
   
   # ...and you can inspect them more closely with .fields
   struct.fields
   #> [<Schema> 'some col': int32, <Schema> 'some other col': string]
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to