Python 不同对象比較大小
2017-06-28 13:41
183 查看
万恶的源泉:
Fireboo的疑问(当然 lambda 本身写的就有问题):
>>> filter( lambda x: x > 2, [ 1, [ 1, 2, 3 ], 2, 3 ] ) [[1, 2, 3], 3]
?:
>>> 1 < [ 1 ] True >>> int < list True >>> dict < int < list True
>>> int < map False
后来几经周折,和 Fireboo 讨论了下,是
1.不同对象比較(除了 number 之外)。是依照 type names 比較,
2.当同样类型对象不支持适当比較的时候。採用 address 比較
3.list 与 list。 tuple 与 tuple 採用字典序比較
>>> x = 1 >>> y = [ 1 ] >>> type( x ) <type 'int'> >>> type( y ) <type 'list'> >>> x < y True
>>> type( int ) <type 'type'> >>> type( list ) <type 'type'> >>> id( int ) 505552912 >>> id( list ) 505555336 >>> int < list True
>>> type( map ) <type 'builtin_function_or_method'> >>> type( list ) <type 'type'> >>> map < list True
相关文章推荐
- Python 不同对象比较大小示例探讨
- Python 不同对象比较大小示例探讨
- Python 不同对象比较大小
- python 之 不同类型对象的内存占用、大小比较
- Python+matplotlib绘制不同大小和颜色散点图实例
- List集合对象中按照不同属性大小排序的实例
- 获取python对象占用空间的大小
- List集合对象中按照不同属性大小排序
- Python open和read功能的不同返回对象
- python--为什么Python有相同的不可变对象id不同?
- python2.7中不同类型之间的比大小
- Python2与Python3在不同类的对象比较上的差异
- python中import的坑--同一模块中的同一对象,实例不同
- 得到当前对象在不同大小的页面中的绝对位置,及冒泡cancelBubble
- python对象的比较(is,==,对象大小比较>,<)
- 【Java基础之集合(三)】集合对象比较大小和比较重复的区别和不同实现
- 一个类的实例化对象所占空间的大小(对象大小= vptr(可能不止一个) + 所有非静态数据成员大小 + Aligin字节大小(依赖于不同的编译器))
- python 对象真假值示例(哪些视为False)
- ArcGIS Engine不同格式数据打开,对象创建,导入导出
- 【cocos2d-x官方文档】不同平台上Cocos2d-x所支持的最大纹理大小