TypeScript 类型系统## TypeScript 类型系统 分享人:陈文岗 学校:中国科学院大学 2021年1月21日 ## 关于TypeScript TypeScript是微软推出的JavaScript静态类型版本,它是JavaScript的超集,可以编译为纯粹的JavaScript TypeScript How Does TypeScript Work? TypeScript file.ts JavaScript jpg) ## TypeScript 基础类型 // 数字类型 let num: number; num = 123; // 布尔类型 let flag: boolean; flag = false; // 字符串类型 let str: string; str = 'Hello World'; ## TypeScript 高级类型 // 数组类型 let arr: number]; arr [1, 2, 3, 4]; // 接口 interface Person { name: string; age: number; } let p1: Person = { name: 'chenwengang', age: 23 }; // 函数类型/函数签名 type Callback = () => void; let cb:Callback0 码力 | 25 页 | 1.27 MB | 2 年前3
Unraveling string_view: Basics, Benefits, and Best PracticesUnraveling string_view: Basics, Benefits, and Best Practices ## JASMINE LOPEZ & PRITHVI OKADE 20 24 September 15 - 20 ## Topics • Motivation • Performance benefits & basics • string_view: Constructors functions • string vs. string_view and their interoperability • When to use string_view • Using string_view safely • Intro to span • span vs. string_view • Case study of an optimization using string_view function foo which operates on an immutable string. • In C++ we generally will create it with the following signature. 1 void foo(const std::string& str); string existing_str; foo(existing_str); foo("hello0 码力 | 61 页 | 1.11 MB | 1 年前3
5 刘知杭 静态类型的Python## 静态类型的Python PYTHON 30th Lyzh(刘知杭) ## 目录 CONTENTS ➤ 有关类型的概念 使用mypy对Python源代码进行静态分析 代数数据类型 拓展知识 ## 关于类型的一些基本概念 有类型不等于有类型系统 PYTHON 30th 动态语言类型化的必要性 ## 不久前的一个案例 ☀️ ☀️ ☁️ rl = filter(lambda x: HttpResponse(json.dumps(rl), content_type='application/json') ## 类型的概念 CPython定义了PyObject这个结构体作为对象头。 CPython中的类型,是指在对象头中指向类型元信息的指针。 ## ●●● // cpython/include/object.h #define PyObject_HEAD PyObject CPython有类型,但CPython没有类型系统。这就是CsPython中诸多问题的由来。 ## 类型系统是什么? 类型系统(type system)是一种编译期(Compile-time)的类型推导检查规则。 类型系统(type system)的基本目标是防止程序在运行时发生类型错误。当且仅当语言运行时不存在任何形式的类型错误,那么它就是sound的。soundness是类型系统研究的重要目标。0 码力 | 42 页 | 6.87 MB | 2 年前3
基本数据类型## PyTorch ## 基本数据类型 主讲人:龙良曲 ## All is about Tensor |python|PyTorch| |---|---| |Int|IntTensor of size()| |float|FloatTensor of size()| |Int array|IntTensor of size \[d1, d2, ...]| |Float array|FloatTensor array|FloatTensor of size \[d1, d2, ...]| |string|--| ## How to denote string One - hot [0, 1, 0, 0, ...] Embedding Word2vec glove ## Data type |Data type|dtype|CPU tensor|GPU tensor| |---|---|---|---| |32-bit0 码力 | 16 页 | 1.09 MB | 2 年前3
MoonBit月兔编程语言 现代编程思想 第四课 多元组, 结构体,枚举类型# 现代编程思想 多元组,结构体与枚举类型 Hongbo Zhang 基础数据类型:多元组与结构体 ## 回顾:多元组 • 多元组:固定长度的不同类型数据的集合 ☐ 定义: $ (\leq $ 表达式 $ \gt $ , $ \leq $ 表达式 $ \gt $ , $ \geq $ ) ☐ 类型:(<表达式类型>,<表达式类型>,...) ○ 例如: ■ 身份信息:("Bob" 身份信息:("Bob", 2023, 10, 24): (String, Int, Int, Int) ☐ 成员访问: ☑ <多元组>.<索引>:(2023,10,24).0 == 2023 • 列表:任意长度的相同类型数据的集合 ○ 例如: ■ 字符的序列:Cons('H', Cons('i', Cons(' Cons('!', Nil))) Cons : construct 的缩写 ## 笛卡尔积 - 一个多元组类型的元素即是每个组成类型的元素构成的有序元素组。集合的笛卡尔积,又称积类型 。例:扑克牌的所有花色: $ \{ $ ♥♠♠♣ $ \}\times\{n\in\mathbb{N}|1\leq n\leq52\} $ : Suit $$ \begin{aligned}&\begin{cases}\\0 码力 | 26 页 | 435.86 KB | 2 年前3
C++高性能并行编程与优化 - 课件 - 10 从稀疏数据结构到量化数据类型{ int x = -7 >> 2; printf("%d\n", x); } 1 ## 位运算 >> 对负数的处理 signed 类型的 >> n 会把最高位复制 n 次。 因为补码的特性,这导致负数 >> 的结果仍是负数。 这样就实现了和 Python 一样的始终向下取整除法。 ## 11001010 printf("%d\n", x); } -2 ## unsigned 类型的位运算 >> 不一样 而 unsigned 类型的 >> n 会不会复制最高位, 只是单纯的位移,这会导致负数的符号位单独被位 移,补码失效,造成结果不对。 unsigned 类型的 >> 会生成 shr 指令,signed 类型的 >> 会生成 sar 指令。 我们需要负方向无限延伸的稀疏数据结果,那就只要 2; } bate::timing("main"); return 0; } ## 使用 int64_t :每个占据 8 字节 • 如果用更大的数据类型,用时会直接提升两倍! 这是因为 i%2 的计算时间,完全隐藏在内存的超高延迟里了。 - 可见,当数据量足够大,计算量却不多时,读写数据量的大小唯一决定着你的性能。 - 特别是并行以后,计算量可以被并行加速,而访存却不行。0 码力 | 102 页 | 9.50 MB | 2 年前3
C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串1. vector 容器初体验 & 迭代器入门 (BV1qF411T7sd) 2. 你所不知道的 set 容器 & 迭代器分类 (BV1m34y157wb) 3. string, string_view, const char * 的爱恨纠葛(本期) 4. 万能的 map 容器全家桶及其妙用举例 5. 函子 functor 与 lambda 表达式知多少 6. 通过实战案例来学习 ‘^\n’ 这个字符。 ## C 语言文字符串 第2章 ## C 语言中的字符类型 char • char c = 'a'; • assert(c == 97); $ c = c + 1; $ • assert(c == 'b'); • C 语言中规定字符类型为 char 类型,是个 8 位整数。 这是因为 ASCII 码只有 0~127 这些整数,而 |0x7F|删除(DEL)|✓|||||||||||| http://c.biancheng.net/ref/ctype_h/ ## 关于 char 类型的一个冷知识 - C 语言其实只规定了 unsigned char 是无符号 8 位整数,signed char 是有符号 8 位整数,而 char 类型只需是 8 位整数即可,可以是有符号也可以是无符号,任凭编译器决定(C 标准委员会传统异能,khronos 直呼内行)。0 码力 | 162 页 | 40.20 MB | 2 年前3
MoonBit月兔编程语言 现代编程思想 第五课 数据类型:树、二叉树、二叉搜索树、AVL树R-Tree:存储空间几何结构 · ..... ## 数据结构:二叉树 - 二叉树要么是一棵空树,要么是一个节点;它最多具有两个子树:左子树与右子树。 - 叶节点的两个子树都是空树 • 基于递归枚举类型的定义(本节课默认存储数据为整数) 1. enum IntTree { 2. Node(Int, IntTree, IntTree) // 存储的数据,左子树,右子树 3. Empty0 码力 | 29 页 | 1015.26 KB | 2 年前3
Nim 2.0.8 Manualstatements / simpleStmt # or a simple statement ## Comments Comments start anywhere outside a string or character literal with the hash character #. Comments consist of a concatenation of comment pieces documentation comment here. ]## You can also use the discard statement together with triple quoted string literals to create multiline comments: discard "" You can have any Nim code text commented html#writing-unitems) test framework. ## I dentifiers & Keywords Identifiers in Nim can be any string of letters, digits and underscores, with the following restrictions: • begins with a letter does0 码力 | 132 页 | 5.73 MB | 1 年前3
Kotlin language specification
Version 1.9-rfc+0.1valid property declaration in Kotlin: val field = 2 even though field is a keyword #### 1.2.5 String mode grammar $ QUOTE\_OPEN $ TRIPLE QUOTE OPEN FieldIdentifier '$\$$ IdentifierOrSoftKey IdentifierOrSoftKey Opening a double quote ( QUOTE_OPEN ) rule puts the lexical grammar into the special “line string” mode with the following rules. Closing double quote ( QUOTE_CLOSE ) rule exits this mode. QUOTE_CLOSE triple double quote (TRIPLE_ QUOTE_OPEN) rule puts the lexical grammar into the special “multiline string” mode with the following rules. Closing triple double quote (TRIPLE_ QUOTE_CLOSE) rule exits this0 码力 | 38 页 | 358.59 KB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
void类型unknown类型never类型number类型string类型string_viewstd::stringspan性能优化内存分配静态类型类型系统mypy鸭子类型结构类型系统PyTorchTensorFloatTensorIntTensor数据类型多元组结构体枚举类型代数数据类型同构稀疏数据结构量化数据类型内存带宽优化int8_tbfloat16C字符串小字符串优化vector树二叉树二叉搜索树二叉平衡树AVL树GuardsLocksModule systemIdentifiersString typeKotlin language specificationannotationslexicallymultiline stringidentifier













