Быстрые конструкции в Python - Олег Шидловский, Python Meetup 26.09.2014Python Meetup
В своем докладе Олег расскажет о замене стандартных функций на более быстрые и об ускорении работы python. Также продемонстрирует несколько примеров быстрых конструкций python.
Ключевые слова, типы, переменные операторы, команды, массивы. По-сути, готовился материал для собеседования, и для закрепления результата была создана данная презентация. Имеется более развёрнутый документ.
Здоровая критика, дополнения и замечания приветствуются.
1. Двоичная система счисления, перевод чисел, битовое представление.
2. Шестнадцатеричная система счисления.
3. Хранение знака: знак в старшем бите (наивный способ).
4. Арифметика по модулю и двоичный дополнительный код.
5. Переполнение.
6. Двоично-десятичный код, Packed BCD.
7. Символы и кодировки: от ASCII к Unicode.
8. Строки, базовые способы их представления.
9. Операции со строками.
10. «Веревки» — альтернативный способ представления строк.
11. Сериализация и десериализация. Пример: сериализация массива чисел переменной длины.
12. Двойственность порядка байт: little-endian и big-endian.
This document discusses using Python and SQLite3 to interact with a SQLite database. It shows how to connect to a database using sqlite3.connect(), get a cursor object using conn.cursor(), execute SQL statements like CREATE TABLE and INSERT using the cursor's execute method, and retrieve data using fetch methods. The goal is to demonstrate basic SQLite database operations in Python like creating tables, inserting data, and querying data.
This document discusses regular expressions (re) in Python. It provides examples of common regex patterns like \d, \s, ., *, +, ?, etc. It also demonstrates how to compile patterns, perform matches, searches, and find all occurrences using functions like re.compile(), re.match(), re.search(), and re.findall(). The document ends by asking if there are any questions.
More Related Content
Similar to Classes: Number, String, StringBuffer, StringBuilder (20)
Ключевые слова, типы, переменные операторы, команды, массивы. По-сути, готовился материал для собеседования, и для закрепления результата была создана данная презентация. Имеется более развёрнутый документ.
Здоровая критика, дополнения и замечания приветствуются.
1. Двоичная система счисления, перевод чисел, битовое представление.
2. Шестнадцатеричная система счисления.
3. Хранение знака: знак в старшем бите (наивный способ).
4. Арифметика по модулю и двоичный дополнительный код.
5. Переполнение.
6. Двоично-десятичный код, Packed BCD.
7. Символы и кодировки: от ASCII к Unicode.
8. Строки, базовые способы их представления.
9. Операции со строками.
10. «Веревки» — альтернативный способ представления строк.
11. Сериализация и десериализация. Пример: сериализация массива чисел переменной длины.
12. Двойственность порядка байт: little-endian и big-endian.
This document discusses using Python and SQLite3 to interact with a SQLite database. It shows how to connect to a database using sqlite3.connect(), get a cursor object using conn.cursor(), execute SQL statements like CREATE TABLE and INSERT using the cursor's execute method, and retrieve data using fetch methods. The goal is to demonstrate basic SQLite database operations in Python like creating tables, inserting data, and querying data.
This document discusses regular expressions (re) in Python. It provides examples of common regex patterns like \d, \s, ., *, +, ?, etc. It also demonstrates how to compile patterns, perform matches, searches, and find all occurrences using functions like re.compile(), re.match(), re.search(), and re.findall(). The document ends by asking if there are any questions.
The document discusses various methods for dictionaries in Python including:
- dict() to create an empty dictionary or initialize with key-value pairs
- clear() to remove all items from a dictionary
- copy() to make a shallow copy of a dictionary
- get() to return a value for a given key or a default if the key does not exist
- has_key() to check if a dictionary contains a given key
- items() to return a list of all key-value pairs as tuples
- iteritems() to iterate over key-value pairs
This document discusses various string methods in Python including capitalize(), lower(), upper(), find(), split(), join(), lstrip(), rstrip(), and strip(). It provides examples of how to use each method on a string and describes what each method does. For example, capitalize() converts the first character to upper case, find() returns the index of the first matched character, and split() returns a list of substrings split on a specified separator.
This document discusses the File class in Java and methods for working with files and directories. It describes the File class's constructors and methods for getting file attributes, checking permissions, renaming, deleting and creating files/directories. It also introduces the FileFilter and FilenameFilter interfaces for filtering files, and provides examples of their use. Finally, it discusses working with dates using the Date and GregorianCalendar classes.
This document discusses Java classes for working with archives and compression. It describes GZIPInputStream and GZIPOutputStream for reading and writing gzip-compressed streams. ZipInputStream, ZipOutputStream, and ZipEntry are covered for reading, writing, and working with entries in zip archives. Examples are provided for compressing/decompressing files using gzip and creating/reading zip archives.
The document discusses input/output streams in Java. It describes common stream classes like FileInputStream, FileOutputStream, BufferedInputStream, BufferedOutputStream, InputStreamReader, OutputStreamWriter, FileReader, FileWriter, BufferedReader and BufferedWriter. It provides examples of reading/writing data to files using methods like read(), write(), readLine() on these classes.
3. Числа Класс java.lang.Number Использование примитивных типов при вычислениях и хранении данных Использование классов-оберток Byte, Short, Integer, Long, Float, Double
4. Методы наследников класса Number byte byteValue() short shortValue() int intValue() long longValue() float floatValue() double doubleValue() int compareTo(Byte anotherByte) int compareTo(Short anotherShort) int compareTo(Integer anotherInteger) int compareTo(Long anotherLong) int compareTo(Float anotherFloat) int compareTo(Double anotherDouble)
5. Класс Integer static final int MIN_VALUE = 0x80000000; static final int MAX_VALUE = 0x7fffffff; static String toString(int i, int radix) static String toHexString(int i) static String toOctalString(int i) static String toBinaryString(int i) static String toString(int i) static int parseInt(String s, int radix) static int parseInt(String s) throws NumberFormatException static Integer valueOf(String s, int radix) throws NumberFormatException
6. Класс Integer static Integer valueOf(String s) throws NumberFormatException static Integer valueOf(int i) Integer(int value) Integer(String s) String toString() static int highestOneBit(int i) static int lowestOneBit(int i) static int bitCount(int i)
7. Вывод числовых данных Методы printf и format public PrintStream printf(String format, Object ... args) public PrintStream printf(Locale l, String format, Object ... args) Форматирование вывода: %[argument_index$][flags][width][.precision]conversion Conversion: d, x, s, c, f, e, n (%n – перевод строки ) Флаги: - - выравнивание по левому краю, 0 – заполнение нулями, + - включение знака, ( - отрицательные символы в скобках
10. Члены String Конструкторы String() String(String original) String(char value[]) String(char value[], int offset, int count) String(byte bytes[], int offset, int length, String charsetName) String(byte bytes[], int offset, int length, Charset charset)
11. Методы String int length() boolean isEmpty() char charAt(int index) int codePointAt(int index) void getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) byte[] getBytes(String charsetName) byte[] getBytes() boolean contentEquals(StringBuffer sb)
12. Методы String boolean contentEquals(CharSequence cs) boolean equalsIgnoreCase(String anotherString) int compareTo(String anotherString) int compareToIgnoreCase(String str) boolean regionMatches(int toffset, String other, int ooffset, int len) boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) boolean startsWith(String prefix, int toffset)
13. Методы String public boolean startsWith(String prefix) public boolean endsWith(String suffix) int indexOf(int ch) int indexOf(int ch, int fromIndex) int lastIndexOf(int ch) int lastIndexOf(int ch, int fromIndex) int indexOf(String str) int indexOf(String str, int fromIndex) int lastIndexOf(String str) int lastIndexOf(String str, int fromIndex)
16. Методы String String trim() char[] toCharArray() static String format(String format, Object ... args) static String format(Locale l, String format, Object ... args) static String valueOf(char data[]) static String valueOf(char data[], int offset, int count) static String valueOf(int i) static String valueOf(double d)
17. Интерфейс CharSequence public interafce CharSequence int length() char charAt(int index) CharSequence subSequence(int start, int end) public String toString()
19. Класс StringBuffer Конструкторы StringBuffer() StringBuffer(int capacity) StringBuffer(String str) StringBuffer(CharSequence seq) int length() int capacity() void ensureCapacity(int minimumCapacity)
20. Методы StringBuffer void trimToSize() char charAt(int index) StringBuffer append(Object obj) StringBuffer append(String str) StringBuffer append(StringBuffer sb) StringBuffer append(CharSequence s) StringBuffer append(CharSequence s, int start, int end) StringBuffer append(char str[]) StringBuffer append(char str[], int offset, int len)
21. Методы StringBuffer StringBuffer delete(int start, int end) StringBuffer deleteCharAt(int index) StringBuffer replace(int start, int end, String str) String substring(int start) CharSequence subSequence(int start, int end) String substring(int start, int end) StringBuffer insert(int index, char str[], int offset, int len) StringBuffer insert(int offset, Object obj) StringBuffer insert(int offset, String str)
22. Методы StringBuffer int indexOf(String str) int indexOf(String str, int fromIndex) int lastIndexOf(String str) int lastIndexOf(String str, int fromIndex) StringBuffer reverse() String toString()
25. Методы StringBuilder StringBuilder append(CharSequence s, int start, int end) StringBuilder append(char str[], int offset, int len) StringBuilder delete(int start, int end) StringBuilder deleteCharAt(int index) StringBuilder replace(int start, int end, String str) StringBuilder insert(int index, char str[], int offset, int len) StringBuilder insert(int offset, Object obj) StringBuilder insert(int offset, String str) StringBuilder insert(int offset, int i)
26. Методы StringBuilder int indexOf(String str) int indexOf(String str, int fromIndex) int lastIndexOf(String str) int lastIndexOf(String str, int fromIndex) StringBuilder reverse() String toString()
28. Методы конвертации Конвертирование из строки в число int i = (Integer.valueOf(str) ).intValue(); int i = Integer.parseInt(str); Конвертирование из числа в строку String str = "" + i; String str = String.valueOf(i); String str = Integer.toString(i);