summaryrefslogtreecommitdiff
path: root/Doc/library
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-37958: Adding get_profile_dict to pstats (GH-15495)Daniel Olshansky2020-01-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pstats is really useful or profiling and printing the output of the execution of some block of code, but I've found on multiple occasions when I'd like to access this output directly in an easily usable dictionary on which I can further analyze or manipulate. The proposal is to add a function called get_profile_dict inside of pstats that'll automatically return this data the data in an easily accessible dict. The output of the following script: ``` import cProfile, pstats import pprint from pstats import func_std_string, f8 def fib(n): if n == 0: return 0 if n == 1: return 1 return fib(n-1) + fib(n-2) pr = cProfile.Profile() pr.enable() fib(5) pr.create_stats() ps = pstats.Stats(pr).sort_stats('tottime', 'cumtime') def get_profile_dict(self, keys_filter=None): """ Returns a dict where the key is a function name and the value is a dict with the following keys: - ncalls - tottime - percall_tottime - cumtime - percall_cumtime - file_name - line_number keys_filter can be optionally set to limit the key-value pairs in the retrieved dict. """ pstats_dict = {} func_list = self.fcn_list[:] if self.fcn_list else list(self.stats.keys()) if not func_list: return pstats_dict pstats_dict["total_tt"] = float(f8(self.total_tt)) for func in func_list: cc, nc, tt, ct, callers = self.stats[func] file, line, func_name = func ncalls = str(nc) if nc == cc else (str(nc) + '/' + str(cc)) tottime = float(f8(tt)) percall_tottime = -1 if nc == 0 else float(f8(tt/nc)) cumtime = float(f8(ct)) percall_cumtime = -1 if cc == 0 else float(f8(ct/cc)) func_dict = { "ncalls": ncalls, "tottime": tottime, # time spent in this function alone "percall_tottime": percall_tottime, "cumtime": cumtime, # time spent in the function plus all functions that this function called, "percall_cumtime": percall_cumtime, "file_name": file, "line_number": line } func_dict_filtered = func_dict if not keys_filter else { key: func_dict[key] for key in keys_filter } pstats_dict[func_name] = func_dict_filtered return pstats_dict pp = pprint.PrettyPrinter(depth=6) pp.pprint(get_profile_dict(ps)) ``` will produce: ``` {"<method 'disable' of '_lsprof.Profiler' objects>": {'cumtime': 0.0, 'file_name': '~', 'line_number': 0, 'ncalls': '1', 'percall_cumtime': 0.0, 'percall_tottime': 0.0, 'tottime': 0.0}, 'create_stats': {'cumtime': 0.0, 'file_name': '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/cProfile.py', 'line_number': 50, 'ncalls': '1', 'percall_cumtime': 0.0, 'percall_tottime': 0.0, 'tottime': 0.0}, 'fib': {'cumtime': 0.0, 'file_name': 'get_profile_dict.py', 'line_number': 5, 'ncalls': '15/1', 'percall_cumtime': 0.0, 'percall_tottime': 0.0, 'tottime': 0.0}, 'total_tt': 0.0} ``` As an example, this can be used to generate a stacked column chart using various visualization tools which will assist in easily identifying program bottlenecks. https://bugs.python.org/issue37958 Automerge-Triggered-By: @gpshead
* Fix typo in multiprocessing.pool.AsyncResult.successful doc. (GH-17932)Antoine2020-01-151-1/+1
| | | | | | | | Since 3.7 `successful` raises a `ValueError` as explained in the next text block from the documentation: _Changed in version 3.7: If the result is not ready, ValueError is raised instead of AssertionError._ No issue associated with this PR. Should be backported in 3.7 and 3.8.
* bpo-38630: Fix subprocess.Popen.send_signal() race condition (GH-16984)Victor Stinner2020-01-151-0/+2
| | | | | | | On Unix, subprocess.Popen.send_signal() now polls the process status. Polling reduces the risk of sending a signal to the wrong process if the process completed, the Popen.returncode attribute is still None, and the pid has been reassigned (recycled) to a new different process.
* Fix AsyncMock base class in the docs (GH-18008)Elena Oat2020-01-151-1/+1
|
* bpo-39329: Add timeout parameter for smtplib.LMTP constructor (GH-17998)Dong-hee Na2020-01-141-1/+5
|
* bpo-38901: Allow setting a venv's prompt to the basename of the current ↵Vinay Sajip2020-01-141-1/+2
| | | | | | directory. (GH-17946) When a prompt value of '.' is specified, os.path.basename(os.getcwd()) is used to configure the prompt for the created venv.
* Fix documentation in code.py (GH-17988)Kyle Pollina2020-01-151-1/+1
|
* bpo-39322: Add gc.is_finalized to check if an object has been finalised by ↵Pablo Galindo2020-01-141-0/+21
| | | | the gc (GH-17989)
* bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)Mark Shannon2020-01-141-0/+21
| | | | | | | | Break up COMPARE_OP into four logically distinct opcodes: * COMPARE_OP for rich comparisons * IS_OP for 'is' and 'is not' tests * CONTAINS_OP for 'in' and 'is not' tests * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
* bpo-39259: smtp.SMTP/SMTP_SSL now reject timeout = 0 (GH-17958)Dong-hee Na2020-01-141-0/+6
|
* bpo-39259: ftplib.FTP/FTP_TLS now reject timeout = 0 (GH-17959)Dong-hee Na2020-01-131-0/+7
|
* bpo-39310: Add math.ulp(x) (GH-17965)Victor Stinner2020-01-132-8/+40
| | | | Add math.ulp(): return the value of the least significant bit of a float.
* bpo-39313: Add an option to RefactoringTool for using exec as a function ↵Batuhan Taşkaya2020-01-121-1/+1
| | | | | | | | (GH-17967) https://bugs.python.org/issue39313 Automerge-Triggered-By: @pablogsal
* bpo-3530: Add advice on when to correctly use fix_missing_locations in the ↵Batuhan Taşkaya2020-01-121-1/+9
| | | | | | AST docs (GH-17172) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
* bpo-39288: Add examples to math.nextafter() documentation (GH-17962)Victor Stinner2020-01-121-0/+7
|
* bpo-12159: Document sys.maxsize limit in len() function reference (GH-17934)Zac Hatfield-Dodds2020-01-121-0/+5
|
* bpo-39288: Add math.nextafter(x, y) (GH-17937)Victor Stinner2020-01-121-0/+8
| | | Return the next floating-point value after x towards y.
* bpo-39259: nntplib.NNTP/NNTP_SSL now reject timeout = 0 (GH-17936)Dong-hee Na2020-01-111-0/+8
| | | | | nntplib.NNTP and nntplib.NNTP_SSL now raise a ValueError if the given timeout for their constructor is zero to prevent the creation of a non-blocking socket.
* bpo-39259: poplib now rejects timeout = 0 (GH-17912)Dong-hee Na2020-01-101-1/+7
| | | | | poplib.POP3 and poplib.POP3_SSL now raise a ValueError if the given timeout for their constructor is zero to prevent the creation of a non-blocking socket.
* bpo-35292: Avoid calling mimetypes.init when http.server is imported (GH-17822)An Long2020-01-081-3/+6
|
* bpo-39242: Updated the Gmane domain into news.gmane.io (GH-17903)Dong-hee Na2020-01-081-4/+4
|
* bpo-38615: Add timeout parameter for IMAP4 and IMAP4_SSL constructor (GH-17203)Dong-hee Na2020-01-071-10/+27
| | | | | | | | imaplib.IMAP4 and imaplib.IMAP4_SSL now have an optional *timeout* parameter for their constructors. Also, the imaplib.IMAP4.open() method now has an optional *timeout* parameter with this change. The overridden methods of imaplib.IMAP4_SSL and imaplib.IMAP4_stream were applied to this change.
* bpo-39239: epoll.unregister() no longer ignores EBADF (GH-17882)Victor Stinner2020-01-071-0/+3
| | | | The select.epoll.unregister() method no longer ignores the EBADF error.
* bpo-38623: Doc: Add section for site module CLI. (GH-17858)Inada Naoki2020-01-071-2/+7
|
* bpo-39234: `enum.auto()` default initial value as 1 (GH-17878)YoSTEALTH2020-01-061-1/+1
| | | | | | | | | | Updated as Eric mentioned "By default, the initial value starts at 1" https://bugs.python.org/issue39234 Automerge-Triggered-By: @ericvsmith
* bpo-39234: Doc: `enum.auto()` incrementation value not specified. (GH-17872)YoSTEALTH2020-01-061-1/+1
| | | * `enum.auto()` initial value is now specified as being `1`.
* Minor formatting improvements and fixes to idle.rst (GH-17165)Tal Einat2020-01-051-7/+8
|
* bpo-39130: Dict reversed was added in v3.8 so should say in the doc as well ↵Khalid Mammadov2020-01-051-0/+2
| | | | | | | | | (GH-17694) To be consistent with document layout, it should say when the feature was added. Although it's mentioned few other places in the doc but it's not explicitly say that at that place. https://bugs.python.org/issue39130
* Add link to zlib v1.1.3 vulnerability (GH-17156)Emmanuel Nosa E2020-01-031-3/+2
|
* bpo-39158: ast.literal_eval() doesn't support empty sets (GH-17742)Raymond Hettinger2020-01-021-0/+3
|
* bpo-39183: Fix formatting in library/ensurepip (GH-17787)Rafael Fontenelle2020-01-011-1/+1
| | | | | | Remove extra space to fix formatting and avoid from splitting text in to strings. https://bugs.python.org/issue39183
* bpo-13601: always use line-buffering for sys.stderr (GH-17646)Jendrik Seipp2020-01-011-3/+9
|
* Document CodeType.replace (GH-17776)Anthony Sottile2020-01-011-1/+7
|
* Minor doc fixes in urllib.parse (GH-17745)Борис Верховский2019-12-311-26/+27
|
* bpo-34118: memoryview, range, and tuple are classes (GH-17761)Terry Jan Reedy2019-12-301-3/+3
| | | | Tag memoryview, range, and tuple as classes, the same as list, etcetera, in the library manual built-in functions list.
* Fix typos and remove deprecated deprecation warning. (GH-17741)Antoine2019-12-291-11/+4
|
* links in importlib.metadata.rst replaced with sphinx references (GH-17730)Oleg Höfling2019-12-291-23/+16
| | | | | | | The importlib.metadata documentation uses hardcoded links to internal pages. This results in minor rendering issues. This change replaces the hardcoded links with suitable Sphinx roles. Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com>
* bpo-39136: Fixed typos (GH-17720)Gurupad Hegde2019-12-282-2/+2
| | | | | funtion -> function; configuraton -> configuration; defintitions -> definitions; focusses -> focuses; necesarily -> necessarily; follwing -> following; Excape -> Escape,
* bpo-38731: Fix function signature of quiet in docs (GH-17719)Batuhan Taşkaya2019-12-281-1/+1
|
* closes bpo-39135: Remove 'time.clock()' mention in docs. (GH17709)Michael Wayne Goodman2019-12-261-1/+0
| | | | | `time.clock()` was removed in Python 3.8, but it was still mentioned in the documentation for when `time.get_clock_info()` is given the argument `'clock'`. This commit removes that mention.
* bpo-33961: Adjusted dataclasses docs to correct exceptions raised. (GH-7917) ↵Fabio Sangiovanni2019-12-251-3/+4
| | | | (GH-17677)
* [typo] fix dupe in datetime.fromisoformat docs (GH-17295)Michael Morehouse2019-12-231-2/+0
| | | | | | | | | Fixes a nearly word for word duplication of a sentence that appears earlier in the caution section of datetime.datetime.fromisoformat in Doc/Library/datetime.rst. No issue created as it's a trivial change. Automerge-Triggered-By: @pganssle
* Add missing markup (GH-17680)cocoatomo2019-12-221-1/+1
| | | "HH", "MM" and "ffffff" are enclosed with double back quotes, but "SS" is left being bare
* bpo-38918: Add __module__ entry for function & method type in inspect docs ↵Parth Sharma2019-12-201-0/+6
| | | | | | | | | | | table (GH-17408) Adds` __module__ ` entries for function & method types in inspect docs table. https://bugs.python.org/issue38918
* Doc typo (#17667)Jesús Cea2019-12-201-1/+1
|
* bpo-38348: Extend command line options of ast parsing tool (GH-16540)Batuhan Taşkaya2019-12-161-0/+9
| | | | Add -i and --indent (indentation level), and --no-type-comments (type comments) command line options to ast parsing tool.
* bpo-39022, bpo-38594: Sync with importlib_metadata 1.3 (GH-17568)Jason R. Coombs2019-12-101-6/+6
| | | | | | | | * bpo-39022, bpo-38594: Sync with importlib_metadata 1.3 including improved docs for custom finders and better serialization support in EntryPoints. * 📜🤖 Added by blurb_it. * Correct module reference
* bpo-39007: Add auditing events to functions in winreg (GH-17541)Steve Dower2019-12-091-0/+49
| | | Also allows winreg.CloseKey() to accept same types as other functions.
* bpo-37228: Fix loop.create_datagram_endpoint()'s usage of SO_REUSEADDR (#17311)Kyle Stanley2019-12-091-5/+19
|
* bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)Victor Stinner2019-12-091-10/+0
| | | | array.array: Remove tostring() and fromstring() methods. They were aliases to tobytes() and frombytes(), deprecated since Python 3.2.