A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-March/138678.html below:

[Python-Dev] boxing and unboxing data types

[Python-Dev] boxing and unboxing data types [Python-Dev] boxing and unboxing data typesSerhiy Storchaka storchaka at gmail.com
Mon Mar 9 10:10:09 CET 2015
On 09.03.15 10:19, Maciej Fijalkowski wrote:
> Not all your examples are good.
>
> * float(x) calls __float__ (not __int__)
>
> * re.group requires __eq__ (and __hash__)
>
> * I'm unsure about OSError
>
> * the % thing at the very least works on pypy

Yes, all these examples are implementation defined and can differ 
between CPython and PyPy. There is about a dozen of similar examples 
only in C part of CPython. Most of them have in common is that the 
behavior of the function depends on the argument type. For example in 
case of re.group an argument is either integer index or string group 
name. OSError constructor can produce OSError subtype if first argument 
is known integer errno. float either convert a number to float or parse 
a string (or bytes).

Python functions can be more lenient (if they allows ducktyping) or more 
strict (if they explicitly check the type). They rarely call __index__ 
or __int__.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4