[Edu-sig] making types matter (notes for beginners)

Wes Turner wes.turner at gmail.com
Fri Jan 25 16:52:10 EST 2019


https://en.wikipedia.org/wiki/Type_theory

https://en.wikipedia.org/wiki/Type_theory#Difference_from_set_theory

https://en.wikipedia.org/wiki/Type_theory#Relation_to_category_theory

https://en.wikipedia.org/wiki/Homotopy_type_theory ("HoTT")

https://en.wikipedia.org/wiki/Type_signature ("Type annotation")

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)#Subtyping

https://en.wikipedia.org/w/index.php?title=Eigenclass_model&oldid=592778140#In_Python

https://en.wikipedia.org/wiki/C3_linearization

Python and data types

https://docs.python.org/3/reference/datamodel.html#objects-values-and-types

https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy

https://docs.python.org/3/library/stdtypes.html

https://docs.python.org/3/library/datatypes.html

https://docs.python.org/3/c-api/intro.html#objects-types-and-reference-counts

https://docs.python.org/3/c-api/type.html#c.PyTypeObject

https://github.com/python/typeshed

https://github.com/python/typeshed/blob/master/stdlib/2and3/math.pyi

https://github.com/python/typeshed/blob/master/stdlib/3/inspect.pyi

...

http://diveintopython3.problemsolving.io/native-datatypes.html

http://composingprograms.com/pages/21-introduction.html

https://www.scipy-lectures.org/intro/language/basic_types.html

https://www.scipy-lectures.org/intro/language/oop.html

http://greenteapress.com/thinkpython2/html/

...

https://twitter.com/javierwchavarri/status/1082597155628568577

> One of the most useful ways to categorize type systems is:
>
> - is it Hindley-Milner based? (Rust, Haskell, OCaml)
> - or does it support implicit subtyping (TypeScript, Flow, C#)?
>
> The first: 1 expression <-> at most 1 type.
> The second: 1 expression <-> multiple types.
>
> A thread 👇

https://en.wikipedia.org/wiki/Hindley–Milner_type_system

https://en.wikipedia.org/wiki/Subtyping

...

https://en.wikipedia.org/wiki/Python_(programming_language)

>From the Python infobox:

> Typing discipline <https://en.m.wikipedia.org/wiki/Type_system>: Duck
<https://en.m.wikipedia.org/wiki/Duck_typing>, dynamic
<https://en.m.wikipedia.org/wiki/Dynamic_typing>, gradual
<https://en.m.wikipedia.org/wiki/Gradual_typing> (since 3.5), strong

https://en.wikipedia.org/wiki/Duck_typing

https://en.wikipedia.org/wiki/Dynamic_typing

https://en.wikipedia.org/wiki/Gradual_typing

https://en.wikipedia.org/wiki/Strong_typing

On Friday, January 25, 2019, kirby urner <kirby.urner at gmail.com> wrote:

>
> In my on ramp to Python, for beginners, I find harping on "types" a great
> intro (if unoriginal -- a lot of us do it).
>
> For one thing, we can hold fixed to the "type" idea while changing the
> source of the type from built-in, to standard library module, to 3rd party
> -- three tiers in my "dimensions of Python".
>
> These dimensions are (again):
>
> * keywords and core syntax (punctuation symbols e.g. [ ] ( ) : etc.)
> * built-ins
> * __ribs__ (special names e.g. __getitem__)
> * standard library
> * 3rd party (or cloud, or ecosystem, most of what you write yourself)
>
> What I say about OO and types is:
>
> this was an attempt to mirror your natural language thinking in terms of
> things having type and thereby characteristics.  Computer languages were
> reaching out to meet us half way, in our native context.  "Easy to reason
> about" in proportion to one's having a strong sense of metaphor perhaps.
> Not self-proving.
>
> The datetime type is, like the string, great for escaping the vortex of
> "number types only" (where high school math teachers seem to wish to
> confine themselves for some reason, although this is not a limitation of
> maths).
>
> Many newcomers to programming expect incessant number crunching and
> languages that only care about numeric methods. That's a stereotype to
> smash early.  Some types help us do that.  I have a "permutation" type
> that's like a number in being very mathy, supports __mul__ and __invert__,
> but it's not a "number" type.
>
> https://repl.it/@kurner/Permutations  (repl.it worth checking out if you
> haven't)
>
> datetime also persuades us to appreciate that others have dealt with the
> complexity.  We get the fruits of their efforts.  Calendar stuff is sooo...
> tedious?  Not forgetting timezones and daylight savings time.  It's a lot
> of useful machinery that used to stay locked away in temples.
>
> A good example of a 3rd party type?  Actually there's a lot of 3rd party
> datetime stuff.
>
> Lets get back to number crunching why not?  gmpy2 - Extended Precision
> Decimals.  Very like decimals in Standard Library, which is great, for
> comparing and contrasting similar types.
>
> A strong focus on types right from the get go then helps explain the power
> of Python's  'class' keyword:  Python lets you extend the type system with
> types of your own.
>
> That's the OO model after all (not at all unique to Python), and meant to
> mirror reality in some ways, a different goal then being "easy to reason
> about" (which is a holy grail as well  -- it's not either/or).
>
> Example using of gmpy2 in a "learning Python" curriculum context:
>
> https://nbviewer.jupyter.org/github/4dsolutions/Python5/
> blob/master/S_Train.ipynb
> (more links from the bottom if wanting more of the same)
>
> The feature I want to emphasize is the results of decimal calculations
> mostly look like this:
>
> JB Icosa:   18.512295868219161196009899292654531923571426913640152615969
> JB Cubocta: 20.000000000000000000000000000000000000000000000000000000000
> SuperRT:    21.213203435596425732025330863145471178545078130654221097650
>
> Not what you'd be seeing with a calculator (too precise).  Not floating
> point numbers, clearly, in the sense of IEEE 754.
>
> I find extended precision types useful for inspiring students to
> developing that special and useful skill, of going from conventional sigma
> notation, to working programs using loops -- what sigmas stand for.
>
> Ramanujan had some doozies converging to Pi (or 1/Pi) or whatever.  We've
> looked at those before on edu-sig.
>
> Example:
> https://github.com/4dsolutions/Python5/blob/master/Extended%20Precision.
> ipynb
>
> Kirby
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20190125/4aac5194/attachment-0001.html>


More information about the Edu-sig mailing list